The less command in Linux

less displays text one screen at a time with full navigation: scroll both ways, search with /, jump to the end with G. It loads lazily, so opening a multi-gigabyte log is instant. Whenever output exceeds a screen — files, man pages, command output — less is where it should land.

How less works

On a file, less seeks: it reads only what the screen needs, jumps to the end via file size, and searches by scanning forward from where you are — which is why a 10 GB log opens instantly. On a pipe, seeking is impossible, so less buffers what has arrived; G ("go to end") on a live pipe means "wait for EOF", a surprise that has puzzled everyone once.

The full-screen behavior comes from terminal control: less switches the terminal to the alternate screen and raw key mode, draws with cursor-addressing escape sequences, and restores your scrollback on quit. -R passes through color escape sequences intact — the flag that keeps piped colored output (grep --color, git) colored inside the pager.

Syntax

less [OPTIONS] FILE   |   CMD | less

Common options

OptionWhat it does
/patternSearch forward (n next match, N previous).
G / gJump to end / beginning.
FFollow mode — tail -f inside less; Ctrl+C returns to browsing.
-NLine numbers.
-SNo wrapping: long lines scroll horizontally (→/←).
-RPass through colors (for piped colored output).
qQuit.

How to use less: examples

$ less /var/log/syslog

Open instantly, then G for the end, /error to hunt.

$ grep -r "TODO" src/ | less

Any command's output, browsable.

$ less +F app.log

Start in follow mode: live log with the full navigation one Ctrl+C away.

$ less -S wide.csv

Wide data without wrapping soup.

Real-world use cases for less

Reading giant logs comfortably

A 12 GB log after an incident: less opens it instantly, G jumps to the end, ?ERROR searches backwards from there, -N adds line numbers for the bug report. The whole investigation without ever loading the file.

Making any output browsable

ps aux, journalctl, diff -r — anything longer than a screen: pipe into less -R (colors intact) and navigate instead of scrolling terminal history. The pager as the universal viewport.

Pro tips and common mistakes

Frequently asked questions about less

less or cat?

cat for under a screenful, less for everything else. cat dumps; less navigates.

Why "less"?

It succeeded the older pager "more" with backwards scrolling — hence the joke: less is more.

How do I search case-insensitively?

Press -i inside less to toggle, or start with less -i. Smart default: lowercase patterns match any case.

Related commands

cat

Print file contents, number lines, and join multiple files together.

grep

Find lines matching a pattern in files or piped input — the workhorse of text search.

head & tail

Print the first or last lines of a file — including live log following with tail -f.

Want to build real fluency? The interactive course takes you through less and every other essential command with guided, checked exercises.