The less
command is a must-know tool for Linux users, offering a lightweight way to view text files or command outputs one screen at a time. Perfect for browsing large logs or configuration files without editing them, less
is fast, efficient, and beginner-friendly. This guide enhances your understanding with practical examples and tips to master less on your Linux system, whether you’re managing a VPS or debugging logs.
When you open a file with less, it doesn’t load the entire file into memory. Instead, it streams the content as you scroll, which makes it very fast and lightweight — even with log files that are several megabytes in size. Unlike text editors like nano or vim, less is non-editable — it’s strictly for reading. This means you can safely open configuration files, logs, or any text file without the risk of accidentally modifying them.
Example:
This will open the system authentication log in less, allowing you to navigate through it with simple key commands.
Key | Function |
---|---|
Space | Scroll forward one page |
b | Scroll backward one page |
Enter | Scroll down one line |
g | Go to the beginning of the file |
G | Jump to the end of the file |
/pattern | Search forward for a keyword (e.g. /error) |
n / N | Repeat search (next/previous match) |
q | Exit less |
These commands make it easy to review logs, search for specific entries, or simply browse through structured files.
Quickly check SSH settings without accidentally changing anything.
Then press /fail to search for lines containing “fail”.
View the full output of the ps aux command without it scrolling off the screen.
-N — Show line numbers:
-S — Chop long lines instead of wrapping them:
+G — Open file and jump straight to the end:
These options enhance how you interact with files in various contexts — from debugging errors to verifying recent log entries.
You can read .gz files without extracting them using zless, a variation of less:
It behaves exactly like less, but works with compressed content — ideal for archived logs.
The less
command is a versatile, lightweight tool that simplifies viewing and navigating text files or command outputs in Linux. With its read-only nature, efficient memory use, and powerful search capabilities, it’s perfect for managing logs, configs, or piped outputs. The examples and tips above help you leverage less
for quick debugging or system management, making it an essential part of your Linux toolkit.