O'Reilly logo

Linux® For Dummies®, 8th Edition by Richard Blum, Dee-Ann LeBlanc

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

Viewing the Contents of a Text File

Almost all configuration files in Linux are text files. In addition, many pseudo-programs (called shell scripts), all HTML documentation, and many other items in your system are text files. Fortunately, if you just want to see what’s in a text file and don’t want to do anything to its contents, you don’t have to use an editor or word processor. You can use three command-line commands to view text files: cat, less, and more. I bet that you will grow to love them.

Yes, that first command is cat, and it’s taken from the word concatenate, which means to bring together end to end — you can use the cat command on multiple-text files to have their text joined, one file’s contents directly after another’s. Typically you use this command in the Linux world in the format cat filename, where the contents of the file filename are displayed on the screen. For example, if you create the short text file greetings and then type cat greetings, you see the following:

 $ cat greetings                                                     
						 These are the contents of the greetings file.                       
						 Meow!                                                               
						 $ _                                                                 

Of course, if the file contains more than a screen’s worth of information, cat spews it all out at one time like a big hairball, and all but the last screen of text scrolls off the screen. It’s a good thing that you have some other choices. The one you’re likely to choose is less, which displays the contents of a file a full screen at a time. Then you press the spacebar to continue to the next screen. You can also use ...

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