Introduction
In Linux, many system files, such as configuration files and scripts, are stored as plain text. The less command offers an effective and safe way to view these files in the terminal without editing or running them.
Using the less command
The less command displays a text file one page at a time and is easier to navigate than older tools.
less filenameExample: viewing user account information:
less /etc/passwdTo quit, simply press q.
What is a text file?
Text files have a simple structure: each character maps to a specific number (such as an ASCII code). These files contain no formatting, only characters, spaces, tabs and line breaks. This simplicity is what makes reading and editing system settings in Linux so easy.
Navigating with less
Useful shortcuts while using less:
| Command | Action |
|---|---|
Page Up / b | Scroll back one page |
Page Down / Space | Scroll forward one page |
| ↑ | Move up one line |
| ↓ | Move down one line |
G | Jump to the end of the file |
1G / g | Jump to the beginning of the file |
/text | Search for a phrase |
n | Find the next match of the previous search |
h | Show the help screen |
q | Quit less |
Why is less better than more?
The less command was designed as a replacement for more, which could only move forward. Besides moving in both directions, less provides searching, built-in help and better handling of large files. These features inspired the famous Unix saying:
"Less is more!"
Conclusion
The less command is an essential Linux tool for viewing text files, especially system configuration files. With smooth navigation, search and a user-friendly design, it has outpaced the traditional tools and is the pager of choice for experienced terminal users.