less(1)
A pager program that displays file contents one screen at a time, allowing backward and forward navigation.
Synopsis
less [OPTION]... [FILE]...Description
less is a terminal pager used to view the contents of text files and command output interactively. Unlike more, it allows you to scroll both forward and backward through content, making it ideal for viewing large files, logs, and command output.
Press q to exit, use arrow keys or j/k to navigate line-by-line, and Space/b for page-by-page scrolling. Search with / (forward) or ? (backward), and jump to the end with G or beginning with g.
Common options
| Flag | What it does |
|---|---|
-N | Display line numbers at the start of each line |
-S | Chop long lines (don't wrap); use arrow keys to scroll horizontally |
-i | Ignore case during searches (unless uppercase is used in search term) |
-I | Always ignore case during searches |
-X | Don't clear the screen when exiting (output remains visible) |
-F | Exit immediately if entire file fits on one screen |
-R | Display ANSI color codes and formatting (raw output) |
-p pattern | Start at the first occurrence of the pattern in the file |
-n | Don't use line numbering internally (faster for huge files) |
+F | Follow file growth in real-time (like <code>tail -f</code>) |
Examples
View system log file with backward/forward navigation
less /var/log/syslogPipe process list through less for interactive browsing
ps aux | lessView password file with line numbers displayed
less -N /etc/passwdOpen logfile and jump to the first occurrence of 'ERROR'
less +/ERROR logfile.txtView kernel messages with color codes preserved
dmesg | less -RView config file with long lines chopped (horizontal scrolling available)
less -S config.txtMonitor a log file in real-time, updating as new content is written
less +F growing.logView file with case-insensitive search enabled
less -i large_file.txt