Quick take: The less command views a file one screen at a time, letting you scroll both ways, search with /, and quit with q. It is the better choice over the older more, which can only scroll forward.
Introduction
When a file is too big to dump with cat, you need a pager — a tool that shows it one screen at a time. less is the modern pager: fast, searchable, and able to scroll in both directions. more is its older, more limited predecessor.
This guide covers navigating and searching within a file, following logs, and the handful of keys that make less efficient.
Syntax
The basic syntax of the less and more command is:
less [OPTIONS] FILE
more [OPTIONS] FILECommon Options and Parameters
The most useful options and parameters for the less and more command:
| Option | Description |
|---|---|
| Space / b | Page forward / page back (less). |
| /text | Search forward (n for next, N for previous). |
| ?text | Search backward. |
| g / G | Jump to the start / end of the file. |
| q | Quit the pager. |
| -N | Show line numbers. |
| -S | Chop long lines instead of wrapping them. |
| +F | Follow mode, like tail -f (press Ctrl+C then F to toggle). |
Practical Examples
Real less and more commands you can run today:
# View a large file
less /var/log/syslog
# View with line numbers
less -N config.conf
# Don't wrap long lines
less -S wide-data.csv
# Follow a growing log inside less
less +F /var/log/app.log
# Page the output of another command
ps aux | less
# Open a file and jump to a search term
less +/error app.logTips and Best Practices
- Inside less, type
/then a term to search,nfor the next match, andqto quit. - Pipe any long output into less (
command | less) to scroll it comfortably. - less's
+Ffollow mode is liketail -fbut lets you press Ctrl+C to scroll back through history, then F to resume following.
Final Thoughts
less is the pager to learn — it reads huge files instantly, scrolls both ways, and searches like a text editor. Remember / to search, G to jump to the end, and q to quit, and you can comfortably read any file or piped output. The mnemonic says it all: “less is more”.
FAQ: less and more Command in Linux
What is the difference between less and more?+
Both display files a screen at a time, but less can scroll backward, search in both directions, and load instantly without reading the whole file first. more only scrolls forward. Use less.
How do I search inside less?+
Press / followed by your term and Enter to search forward, then n for the next match and N for the previous. Use ? to search backward.
How do I quit less?+
Press q to exit the pager and return to the shell. This works in less, more, and man pages, which all use the same viewer.
How do I view a file with line numbers in less?+
Start it with -N (less -N file), or type -N inside less to toggle line numbers on and off.
How do I follow a log file with less?+
Open it with less +F file, which behaves like tail -f. Press Ctrl+C to stop following and scroll back, then press F to resume following.
Need help with Linux servers or infrastructure?
Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.
Hire Me for Support