Linux commands: less

A quick guide to the less command to display the contents of a file

ThislessCommand is the command I use often. It shows you the content stored in the file with a beautiful interactive UI.

usage:less <filename>.

Once you enterlessDuring the session, you can log out by pressingq.

you can use itupwithdownKey, or usespace barwithbBrowse page by page. You can also press the following button to jump to the end of the fileGThen jump back to start pressg.

You can press to search the contents of the file/And enter the word you want to search. This searchforward. you can use it?Symbol and enter a word.

This command only visualizes the contents of the file. You can open the editor directly by pressingv. It will use the system editor, in most cases,vim.

Press downFKey inputFollow mode, OrViewing mode. When the file is changed by someone else (for example from another program), you will see the changelive. This does not happen by default, and you only see the file version when you open the file. You need to pressctrl-CExit this mode. In this case, the behavior is similar to runningtail -f <filename>command.

You can open multiple files and use:n(Go to the next file) and:p(Go to the previous one).

This command can be used in Linux, macOS, WSL and wherever you have a UNIX environment

Download mine for freeLinux Command Manual


More cli tutorials: