Sometimes you want to quickly read a text file such as a configuration file without having to open a text editor. This is possible with the less, more, and cat command-line utilities. All three have the same basic syntax but work differently and have different commandline options. To use them in their default modes, type the command followed by the text file to read such as less output.txt, more /var/loasg/messages, or cat /etc/sysconfig/ network.
With the less command, the Page Up and Page Down keys can be used to scroll up and down the contents of the file. The more command only allows you to scroll down the file using the spacebar to advance. The cat command outputs the contents of the file to the command line and then exits, so if the file is longer than the number of lines in your terminal, you will only see the last part of the file.
The cat command can also be used in conjunction with the grep command that was previously discussed with the history command. For example, to view only the kernel messages in the system log file, use the following command:
cat /var/log/messages | grep kernel
Because only root can view this file, you need to be logged in as the root user to view the contents. Are you already logged in as a user? Read the article “How to Become the Root User” to find out how to perform administrative tasks while logged in as a user.