+1 607 252-6647 Email Questions

Using less to view text files at the Linux command line

  • Hits: 37

If there's one thing you're sure to find on a Linux system, it's text files. A lot of them. Readme files, configuration files, documents, and more.

Most of the time, you probably open text files using a text editor. But there is a faster and, I think, better way of reading text files. That's using a utility called less[1]. Standard kit with all Linux distributions (at least the ones I've used), less is a command-line textfile viewer with some useful features.

Don't let the fact that it's a command-line tool scare you. less is very easy to use and has a very shallow learning curve.

Let's take a look at some of the things that you can do with less.

Getting started

Crack open a terminal window and navigate to a directory containing one or more text files that you want to view. Then run the command less filename, where filename is the name of the file you want to view.

The file takes over your terminal window, and you'll notice a colon (:) at the bottom of the window. The colon is where you can type any of the internal commands you use with less. More on these in a moment.

Moving around

Chances are that the text file you're perusing is more than a couple of lines long; it's probably a page or more. With less, you can move forward in the file in a few ways:

  • Move down a page by pressing the spacebar or the PgDn key
  • Move down one line at a time by pressing the Down arrow key

less also allows you to move

Read more from our friends at Opensource.com

Contact us

By Mail

PO Box 5613

Katy, TX 77491


Phone: +1 607 252-6647

Fax: +1 866 573-1096