Linux systems contain numerous human-readable text files, including configuration files and scripts that define system behavior. The less command provides a simple and efficient way to view these files without modifying them.
This article explores how less works, the significance of text-based file formats, and useful keyboard shortcuts for navigation.
Using the less Command
The less command allows viewing text files one page at a time, making navigation easier. The basic syntax is:
less filename
For example, to examine the file containing user account information, run:
less /etc/passwd
Once opened in less, you can scroll forward and backward through the file. To exit, simply press q.
What Is Text?
Text files are a simple data format where characters are mapped to numbers, enabling easy storage and retrieval of information.
One of the earliest encoding systems is ASCII (American Standard Code for Information Interchange), which assigns a unique number to each character. Unlike word processor documents (such as those from Microsoft Word or LibreOffice Writer), ASCII text files do not contain formatting elements—they store plain characters with a few basic controls like tabs and line breaks.
Since Linux stores many system configurations as text files, users can easily read and modify settings using basic tools. Even Windows recognizes the importance of plain text with its Notepad program.
Navigating with less
The less command provides smooth navigation through files, with several useful keyboard shortcuts:
Command | Action |
Page Up / b | Scroll back one page |
Page Down / Space | Scroll forward one page |
Up Arrow | Move up one line |
Down Arrow | 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 specific word or phrase |
n | Find the next occurrence of the previous search |
h | Open the help screen |
q | Exit less |
Why less Is Better than more
The less command was developed as an improved alternative to the older Unix more command.
While more only allowed forward navigation, less supports scrolling in both directions, along with additional features such as text searching.
This led to the famous Unix phrase: "Less is more!"—inspired by modern design philosophies.
Conclusion
The less command is an essential tool for viewing text files in Linux, especially system configuration files. With its smooth navigation, search capabilities, and improved usability, it provides a more efficient way to browse long documents compared to older alternatives.