Less Command


The less command is a program to view the content of text files. As per the less manual, less program is similar to more program, but it allows both forward and backward movement in a file and it does not read the entire input file before starting, so with larger input files less is faster than text editors like vi.

less program is the replacement of the more program. It displays the content of a file in page by page manner and thus falls into the pager program category.

[yusuf@linux ~]$ less filename


[yusuf@linux ~]$ less hello.txt

line 1
This is line number 2.
3rd Line
Line Number 4
Line 5
6th Line
hello.txt (END)

Content of a file using the less command in terminal.

How to exit less?

We use the q key to exit less.

Commonly used less commands

Up ArrowScroll up one line
Down ArrowScroll down one line
bScroll back one page
SpaceScroll forward one page
1GMove to the beginning of the text file
gMove to the beginning of the text file
GMove to the end of the text file
/charactersSearch for the next occurrence of the characters
nSearch for the next occurrence of the previous search
hDisplay help
qQuit less

Help screen of the less