System Log Files

Most log files are found in /var/log Checking logs are critical to see if things are working correctly


Kernel Ring Buffer

The kernel ring buffer is something like a log file for the kernel; however, unlike other log files, it’s stored in memory rather than in a disk file.

You can use the dmesg command to view it. Many times it is logged to /var/log/dmesg as well. It requires sudo privileges to read the /var/log/dmesg file, but not to run the dmesg command.


Viewing log files

There are a number of commands to view log files.

Anytime a new entry is added to a log file, it is appended to the end of the file. This is one of those times where tail is particularly useful. Usually when we want to look at log files we want to look at the most recent entries.

When organizing our viewing command - order matters. Most of the following commands produce different results. And all are useful depending on what type of results you want. Go through the thought process and figure out what each command does. Can you figure out which three produce identical results?

If you add the -f option to the tail command it provides a live watch of the log file. This is helpful when trying to watch any error messages produced as you test certain functionality, such as logging in or running a specific program.

Note that log files show info for all users and processes. If you are looking for something specific you may want refine your results with grep.


The log files

/var/log/syslog or /var/log/messages

/var/log/<some application>


Log Files

Log files are frequently rotated or archived to keep the log files from getting too big and time-conuming to read. Meaning that the oldest log file is deleted, the latest log file is renamed with a date or number, and a new log file is created. For instance, if it’s rotated on December 1, 2012, /var/log/messages will become /var/log/messages-20121201, /var/log/messages-1.gz, or something similar, and a new /var/log/messages will be created. This practice keeps log files from growing too large.


Types of Log Files

Log Files found on Scratch

Other log files not found on Scratch


Textbook Time

There is no textbook reading for this section


Last Updated 12/15/2017