less command in linux allows you to display the content of the file, search a word. Navigate to pages and lines.
less command in linux | It's features | with examples
![]() |
less command in linux |
Hello, guys welcome to the next session on Linux command line tutorial. In this session, we will see how we can use "less command" in Linux.
"less command" is used to read the files or if you want to search something inside the file something like patterns or some word.
Then you can use "less" command conveniently to read or search in the file.
So let's see how we can use it.
First of all, I will navigate to my desktop where the "bigfile.txt" file is there.
For example, I want to see the content of this "bigfile.txt" text file. You can also use the "cat" command to read a file. But there is a drawback.
That's why we can use "less command" to overcome these problems. And also "less" has its own features.
less command
![]() |
less command to read a file |
$less fileName
Now I'm going to use "less" for reading the file content. So first of all for using less you just need to write less and the name of the file which is "bigfile.txt" and press ENTER.
![]() |
less command example |
And you can see it will show you the content of the file from the starting. So this is the starting of the file and it'll show you some text until this terminal allows to show.
To go one line Down
down arrow
If you go on to see the content of the file more. You can hit the "down arrow" key.
So down arrow key allows you to go one line down at a time.
To go one line up
up arrow
And if you hit "up arrow" then you can read up or you can browse over the file in the up.
Go to Next page
space bar key
If you want to go through the file, page by page, You can use a "space key" to navigate to your file, page by page.
So when I press a "space" it's going to show me the next page.
Go to the previous page
b
Now if you want to go the previous page by page. You can just press "b" and you will go one page up at a time.
Go to end of file
Shift + G
If you want to go to the end of the file. You can just press "Shift + G" and browse to the end of your text file.
Go to the beginning of the file
lg
If you want to go to the top at the starting of your file. You can just type "1g"
It will go at the beginning of the file.
Search Forward
/searchTerm
I want to search something inside this text file from "up to down".
So I can use this forward-slash (/). Which says this "less" that I want to search from up to down.
![]() |
To find a word using less command |
For example, You are looking for the word "cat" inside this text file just type "/cat" press ENTER.
It's going to show you or highlight the first "cat" keyword. Which you are searching for.
Jump to next iteration
n
Now to search or to go to the next "cat" in the text file. You can press "n" to go to the next item.
Search Backward
?searchTerm
Sometimes you may want to search from down to up.
And for this, you can use this question mark (?) for searching from down to up and then you can give your keyword.
which you are looking for and press ENTER.
Quit less command
Q
Now if you want to "quit" less command. You just need to press "Q" it'll quit your less command.
Conclusion
So this is how you can use "less command" in Linux.
And if you want to know more about less you can just write "man less".
This will show you the description of less command and the flags and the keys. You can use it with less command.
I hope you enjoyed this tutorial kindly rate comment and bye for now.
HAVE A NICE DAY 💖