less Cheatsheet
Basic Usage
Common ways to open files and piped output in less.
| Command | Description |
|---|---|
less file.txt |
Open a file in the pager |
less /var/log/syslog |
Read a system log file |
command | less |
Pipe command output into less |
less +G file.txt |
Open a file and jump to the end |
less +/pattern file.txt |
Open a file and jump to first match |
Navigation Keys
Move through content quickly in the pager.
| Key | Description |
|---|---|
Space |
Move forward one page |
b |
Move backward one page |
Enter |
Move forward one line |
k / y |
Move backward one line |
d / u |
Move forward / backward half a page |
g |
Jump to top of file |
G |
Jump to bottom of file |
50g |
Jump to line 50 |
F |
Follow mode — stream new content as it is appended (press Ctrl+C to stop) |
q |
Quit less |
Search and Match Navigation
Find text and move between matches.
| Key | Description |
|---|---|
/pattern |
Search forward for pattern |
?pattern |
Search backward for pattern |
n |
Next match in current search direction |
N |
Previous match in current search direction |
&pattern |
Show only lines matching pattern |
& (empty) |
Clear &pattern filtered view |
Useful Options
Flags that improve readability in daily use.
| Command | Description |
|---|---|
less -N file.txt |
Show line numbers |
less -S file.txt |
Disable line wrap (horizontal scrolling) |
less -R file.txt |
Show ANSI colors in output |
less -i file.txt |
Case-insensitive search by default |
less -F file.txt |
Quit automatically if content fits one screen |
less -X file.txt |
Keep screen content after quitting |
Log and Output Workflows
Practical examples for troubleshooting and analysis.
| Command | Description |
|---|---|
less +F /var/log/syslog |
Follow a log file live (like tail -f); press Ctrl+C to stop and search |
journalctl -xe | less |
Page through recent systemd logs |
dmesg | less |
Inspect kernel messages page by page |
ps aux | less |
Browse long process listings |
git log | less |
Read long commit history safely |
grep -R "ERROR" /var/log | less |
Review search results interactively |
Troubleshooting
Quick fixes for common less issues.
| Issue | Check |
|---|---|
| Search does not find expected text | Retry with exact case or use -i for case-insensitive search |
| Color codes look broken | Use less -R when input includes ANSI colors |
| Lines wrap and are hard to read | Use less -S and move sideways with arrow keys |
| Pager exits immediately | Content may fit one screen; remove -F if you need manual paging |
| You opened from pipe and lost context | Rerun command with | less and search using /pattern |
Related Guides
Use these guides for deeper command and text-processing workflows.
| Guide | Description |
|---|---|
| less Command in Linux | Full less tutorial with examples |
| head Command in Linux | Show the first lines of files |
| tail Command in Linux | Follow file growth and recent lines |
| grep Command in Linux | Search text patterns in files |
| wc Command in Linux | Count lines, words, and bytes |
