In the Linux system, there are very long text files, such as system log files. To be able to view long text files easily, you can use the less
command.
What is the less command?
Table of Contents
The less command is a program designed to replace a previously existing command on Unix that is more
. The word less
comes from the phrase “less is more“, which is the motto of modern architects.
Like the more
command, the less
command lets you view the content of a text file as pages, which is crucial when you want to see the content of a very long text file. Other than the more
command can only view the page forward, the less
command can view the page backward.
Use the less command to view long text
Less
command is very simple to use, you just need to type the command and followed by the file name (or absolute path to the file).
The table below lists the most common keyboard commands used by less:
Key | Action |
Page Up or b | Scroll back one page |
Page Down or space | Scroll forward one page |
Up Arrow | Scroll up one line |
Down Arrow | Scroll down one line |
G | Move to the end of the text file |
1G or g | Move to the beginning of the text file |
/characters | Search forward to the next occurrence of characters |
n | Search for the next occurrence of the previous search |
h | Display help screen |
q | Quit less |
Conclusion
For long text files on linux, you will often have to use the less
command and hopefully through this article, those who are new to Linux will use it more easily.
(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).