less
read a long fileless is a pager: it shows one screen of a file and waits. You can scroll both ways, jump to the end, and search, and it opens huge files instantly because it reads only the part being shown.
cat prints and leaves; less lets you move around. Press q to quit.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
less fills the terminal and stops. Nothing more is read until you scroll.
The pattern appears on the bottom line. Enter jumps to the first match and highlights every one; n moves to the next.
It means less is waiting for a key: q to quit, G for the end, g for the start, h for help.
Piping a long command into less gives the same scrolling and searching for output that would otherwise fly past.
Switches
A switch changes how the command behaves. These are the ones used day to day; man less lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-N- Show line numbers.
-S- Do not wrap long lines; scroll sideways instead.
-i- Ignore case when searching, unless the pattern has capitals.
-R- Show colours from commands that produce them.
+G- Start at the end of the file.
+F- Follow the file as it grows, like tail -f.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
less +G app.logOpens the file at its end, where the newest log lines are.
less -N script.shShows line numbers down the left.
less -S wide.csvDoes not wrap long lines; scroll sideways with the arrow keys.
less +F app.logFollows the file as it grows, like tail -f. Ctrl+C returns to normal scrolling.
In cybersecurity
A pager is a small program with more abilities than it appears to have.
Typing !command inside less runs it. If sudo allows a user to run less as root, that user has a root shell.
less shows control characters as visible symbols instead of sending them to the terminal, so a hostile file cannot rewrite your screen.
Opening a log in less changes nothing and is not recorded, which is right for an investigation — and worth remembering about anyone else with read access.