$linuxjunkies
>

less(1)

A pager program that displays file contents one screen at a time, allowing backward and forward navigation.

UbuntuDebianFedoraArch

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

FlagWhat it does
-NDisplay line numbers at the start of each line
-SChop long lines (don't wrap); use arrow keys to scroll horizontally
-iIgnore case during searches (unless uppercase is used in search term)
-IAlways ignore case during searches
-XDon't clear the screen when exiting (output remains visible)
-FExit immediately if entire file fits on one screen
-RDisplay ANSI color codes and formatting (raw output)
-p patternStart at the first occurrence of the pattern in the file
-nDon't use line numbering internally (faster for huge files)
+FFollow file growth in real-time (like <code>tail -f</code>)

Examples

View system log file with backward/forward navigation

less /var/log/syslog

Pipe process list through less for interactive browsing

ps aux | less

View password file with line numbers displayed

less -N /etc/passwd

Open logfile and jump to the first occurrence of 'ERROR'

less +/ERROR logfile.txt

View kernel messages with color codes preserved

dmesg | less -R

View config file with long lines chopped (horizontal scrolling available)

less -S config.txt

Monitor a log file in real-time, updating as new content is written

less +F growing.log

View file with case-insensitive search enabled

less -i large_file.txt

Related commands