Privacy Policy
© 2025 linux101.dev

less Command Cheatsheet

The less command is a powerful pager used to view the contents of a file one screen at a time. Unlike `cat`, it's non-destructive and highly efficient for large files because it doesn't load the entire file into memory.

Basic Usage and Options

CommandDescription
less [FILE]Opens the file for viewing.
-SPrevents line wrapping. Lines that are too long for the screen will be truncated, and you can scroll horizontally to see them.
-NDisplays line numbers at the beginning of each line.
+FStarts `less` in "follow mode," similar to `tail -f`. It continuously displays new content as it's added to the file. Press `Ctrl-c` to exit follow mode.

Navigation and Searching

Once you are inside `less`, you can use these keys to navigate and search.

KeyAction
Spacebar or fScrolls forward one screen.
bScrolls backward one screen.
gGoes to the beginning of the file.
GGoes to the end of the file.
/pattern**Searches forward for a regular expression pattern.**
?patternSearches backward for a regular expression pattern.
nMoves to the next match of the search pattern.
NMoves to the previous match of the search pattern.
qQuits `less`.