← Linux and the Command Line Lesson 15 of 51 · 5 XP

more and less — viewing page by page

Theory

Machine translation, not yet reviewed by a native speaker.

When a file is longer than the screen, cat is useless: everything flies past. For reading there are pagers.

more is old and simple: Space — the next page, q — exit. It can't scroll back.

less is modern. The name is a joke: "less is more".

less /var/log/syslog
ps aux | less               # any long output — through less
key in less action
Space / b a page forward / back
↑ ↓ one line
g / G to the start / to the end
/word search forward (n — the next match)
?word search backward
F "follow" mode, like tail -f (Ctrl+C to leave it)
q exit

less doesn't load the whole file into memory, so it opens gigabyte-sized logs without trouble.

The same keys work in man: the manual is shown through less. Searching with / in man is the fastest way to find the option of a command you need.

Our mini Linux has both: less and more.

Try it yourself: Programmers' Room → Linux · sh.

Sign up for free to mark finished lessons and track your progress.