less is an interactive pager: a program for viewing text files or piped input one screen at a time, with scrolling, searching, and navigation. Its name is a joke on more, the older and less capable pager ("less is more"). Unlike more, less can scroll backwards and handle enormous files without loading them into memory.
Common keybindings (mostly vi-like):
- Space / b — forward/back one page
- d / u — half-page
- j / k — one line
- g / G — start/end of file
- /pattern — search forward
- ?pattern — search backward
- n / N — next/previous match
- q — quit
less is the default pager for man, git log, git diff, systemctl status, and many other tools, which is why typing q to quit feels so ingrained. Setting PAGER=less and LESS=-R in your environment enables colour passthrough so that git diff | less shows colour.
For viewing log files, less +F starts less in "follow" mode like tail -f but lets you press Ctrl+C to stop following and scroll around, then F to resume—combining the best of both tools.
Discussed in:
- Chapter 8: Text Processing — Viewing Files
Also defined in: Textbook of Linux