less (Opposite of more)
less is a powerful and fast terminal pager used to view the contents of a text file. Unlike cat or vi, less does not need to read the entire file before starting, resulting in much faster load times for large files. It also allows for both forward and backward navigation.
1. Basic Usage
less [filename]
2. Navigation & Essential Shortcuts
| Key | Action | Description |
|---|---|---|
| Space / f | Page Down | Scrolls forward one full screen. |
| b | Page Up | Scrolls backward one full screen. |
| j / k | Line Down/Up | Moves down or up by exactly one line. |
| G | End of File | Jumps to the very last line of the file. |
| g | Top of File | Jumps to the very first line of the file. |
| /pattern | Search Forward | Searches for a string from the current position downwards. |
| ?pattern | Search Backward | Searches for a string from the current position upwards. |
| n / N | Next / Previous | Moves to the next (n) or previous (N) search match. |
| q | Quit | Exits the less pager. |
3. Practical Examples
① Viewing huge log files
Perfect for files that are too large for standard text editors.
less /var/log/auth.log
② Opening multiple files
You can open several files and switch between them using :n (next) and :p (previous).
less file1.txt file2.txt
4. [Tip] Why we say "Less is More"
In Linux, there's a pun: "less is more, but more than more." This refers to less being a replacement for the older more utility with significantly improved navigation and performance features.