less / more
less and more are commands for viewing file contents one page at a time. They are commonly used to read large log files or manual pages. less offers more features than more and is the preferred choice in modern usage.
Syntax
less [options] [file] more [options] [file]
Options and Key Bindings
| Option / Key | Description |
|---|---|
| less file | Opens a file in paged view. |
| less -N file | Displays line numbers. |
| less -S file | Disables line wrapping; long lines can be scrolled horizontally. |
| less +G file | Opens the file starting from the last line. |
| less +F file | Opens the file in real-time follow mode, equivalent to tail -f. |
| q | Quits less / more. |
| Space / f | Moves forward one page (one screen). |
| b | Moves back one page (less only). |
| ↑ / ↓ or j / k | Scrolls one line at a time (less only). |
| g / G | Jumps to the first / last line (less only). |
| /keyword | Searches forward for a keyword (less only). |
| n / N | Moves to the next / previous search result (less only). |
| h | Displays help (less only). |
Sample Code
Opens a file in paged view. A prompt (:) appears at the bottom of the screen, and you can navigate with key bindings.
less /var/log/syslog
Displays a file with line numbers. Useful for reviewing scripts.
less -N script.sh
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 echo "Hello, World!"
5 echo "Today is $(date)"
:
Pages through output received from a pipe.
grep "ERROR" app.log | less
Monitors a file in real time (similar to $ tail -f). Press Ctrl+C to stop monitoring and switch to normal less navigation.
less +F /var/log/app.log 2026-03-06 12:00:01 [INFO] Server started 2026-03-06 12:00:05 [INFO] Connection accepted 2026-03-06 12:00:12 [WARN] Slow query detected Waiting for data... (interrupt to abort)
Views a file with long lines without wrapping. Use the left and right arrow keys to scroll horizontally.
less -S wide_csv_file.csv
Type /ERROR inside $ less to search for lines containing "ERROR". Press n to jump to the next result, and N to go back to the previous one.
less /var/log/app.log # Type /ERROR after opening to search
The $ man command uses $ less internally. You can navigate it with the same key bindings.
man bash
$ more is a simpler pager that does not support scrolling back to previous pages. Use it for quick, straightforward viewing.
more /etc/fstab
Notes
Unlike $ more, $ less does not load the entire file into memory at once, so it can open even multi-gigabyte log files quickly. It also supports backward navigation. When used with a pipe, it reads from standard input (e.g., grep "ERROR" app.log | less).
To follow the end of a file in real time, tail -f is also commonly used. To display an entire file at once, see cat.
If you find any errors or copyright issues, please contact us.