O'Reilly logo

Raspberry Pi For Dummies by Mike Cook, Sean McManus

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Slowing Down the Listing and Reading Files with the Less Command

The problem with ls is that it can deluge you with information that flies past your eyes faster than you can see it. If you use the LX Terminal from the desktop environment, you can use a scrollbar to review information that has scrolled off the screen.

The more usual solution, however, is to use a command called less, which takes your listing and enables you to page through it, one screen at a time. To send the listing to the less command, you use a pipe character after your listing command, like this:

ls | less

When you’re using less, you can move through the listing one line at a time using the up and down cursor keys, or one page at a time using the Page Up (or b) and Page Down (or space) keys. You can search by pressing / and then typing what you’d like to search for and pressing Enter. When you’ve finished, press the Q key (upper- or lowercase) to quit.

tip.eps You can cancel a Linux command, including an overwhelming listing, by pressing Ctrl+C.

You can also use less to view the contents of a text file by giving it the filename as an argument, like this:

less /boot/config.txt

This is a great way to read files you find as you explore Linux. The less command warns you if the file you want to read might be a binary file, which means it’s computer code and likely to be unintelligible, so you can try using the less command ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required