What is less
less is a terminal pager — it lets you read files or command output one screen at a time, moving freely forward and backward. Unlike cat, it does not dump the entire file at once, which makes it ideal for large files and long outputs.
Basic usage
less filename
less /var/log/syslog
command | less
You can also open multiple files at once:
less file1.txt file2.txt
Use :n to go to the next file and :p to go back to the previous one.
Navigation
| Key | Action |
|---|---|
Space / f |
Forward one page |
b |
Backward one page |
d |
Forward half a page |
u |
Backward half a page |
j / ↓ |
Forward one line |
k / ↑ |
Backward one line |
g |
Go to first line |
G |
Go to last line |
q |
Quit |
Searching
Search forward with / and backward with ?:
/error search forward for "error"
?warning search backward for "warning"
n next match
N previous match
Searches support basic regular expressions:
/^ERROR lines starting with ERROR
/failed.*disk lines with "failed" followed by "disk"
Follow a file in real time
The -F flag makes less behave like tail -f — it keeps reading the file as new lines are added:
less +F /var/log/syslog
Press Ctrl+C to stop following and return to normal navigation mode.
Open at a specific line or pattern
less +100 file.txt open at line 100
less +/pattern file.txt open at first match of pattern
Useful options
less -N file.txt show line numbers
less -S file.txt chop long lines instead of wrapping
less -i file.txt case-insensitive search
less -X file.txt keep content on screen after quitting
Practical examples
View a compressed log without decompressing it first:
zless /var/log/syslog.gz
Read the output of a long command:
grep -r "error" /var/log/ | less
dmesg | less
journalctl | less
Search for errors in a log and read context around them:
less /var/log/nginx/error.log
Then type /404 to jump to the first 404 error.
See also
man less — full reference for all options and interactive commands.
- Created: August 4, 2007
- Last edited: July 7, 2026