When to use less
Use less to inspect long files interactively without dumping them into the terminal. Search inside the viewer and quit back to the shell when finished; this is a viewing tool rather than a text editor.
Syntax
less [OPTIONS] FILESquare brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Open log
less -N ./app.logThe log opens with line numbers for easier navigation.
Read wide table
less -S ./report.tsvLong lines can be scrolled horizontally instead of wrapping.
Open command output
journalctl -u nginx --no-pager | lessService journal output is passed to the pager after disabling the journal's own pager.
Notes and limitations
- In the viewer, / starts the search, n repeats it, q closes the view.
- In +F mode, first press Ctrl+C to go to normal viewing; then q.
Common questions and troubleshooting
How do I leave less or search within it?
Press q to quit. Type a slash followed by a search pattern and Enter, then use n for the next match.
Why does less behave differently in a script?
A pager expects an interactive terminal. For automation, use noninteractive filters and explicit output rather than waiting for keyboard input.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man less.