Ubuntu

How to view system log files in Ubuntu.

System log files are the records that contain all the valuable information of the activities that are happening within the system. The data comprises information about running programs, services, system problems, and kernel messages. The log files are produced automatically to monitor all the events in your system. Almost every program you use creates a log file or contributes to one. Everything on your computer, from the operating system to the apps on your phone, creates log files. It is necessary as they provide information that is not accessible from anywhere else.

Log files are important in post-error investigations. You can utilize log files to figure out what’s causing an issue or a security breach. This is because the log files capture data simultaneously as any information enters into the system. For example, you can find out who was the last active user account before the problem. You’ll also be able to tell if the error was deliberate or unintentional based on the number of tries to penetrate the security system. In this article, we will show you how to view the system log files of your system.

How to view system log files in Ubuntu

You can view the system log files by using the two methods that are mentioned below.

  • Viewing system files using the ubuntu software manager
  • Viewing system files using the terminal.

Let’s discuss the above mentioned approaches:

How to view the system log files using the GNOME Logs app

First, you need to get any log file manager available in the Ubuntu software Center to view the system log files. Open the ubuntu software Center, type “Log” in the search bar:

You can see in the above image that there are a total of three applications available. So, you can install any of the mentioned applications to view the system log files. For example, let’s install the first application with the name “Gnome Logs“. You can do that by selecting this application and then click on the install button that can be seen below:

After its installation, you can open it using the application manager and type “log” in the search bar below:

After opening this application, you will find the “system” tab, as shown below, click on this tab to view the system log files. You will see the timestamp and also all the activities that have happened at a specific time.

If you want to see the system log files from any previous date, then you can do that by clicking on the “Logs” tab, which is present in the top middle. Click on it to view a list of dates along with a time. You can select any date as per your requirement, as shown below:

There are so many system log files, and it is very time-consuming and hectic to find a specific file that you are interested in. So, If you are looking for a particular keyword in a system log file, you can do that by clicking on the Search tab and then type the required keyword you are looking for, as shown below:

How to view the system log files using the terminal

You can also view the system log files by using the below-mentioned command:

$ dmesg

This command will retrieve all the stored messages in the kernel’s memory, as shown below.

Sometimes this command is restricted and you need to remove its restriction to make this command work. Execute the below mentioned command:

$ sudo sysctl kernel.dmesg_restrict=0

System log files can also be viewed using the “Cat” command. For this, execute the below mentioned command:

$ cat /var/log/syslog

Here /var/log/syslog shows the directory where the system log files are present. The output of the above command can be shown in the image below:

You can also write your own custom messages in the system log files to remind yourself later about the information displayed in the system log files. This can be possible using the command:

$ logger "This is a custom message"

Its output can be seen at the end of the system log file by typing $cat /var/log/syslog again in the terminal, as shown below.

Conclusion

System log files are the records that record all the activities that take place within a system, so they provide valuable information about the activities that occur there. Log files are produced automatically as soon as any activity started in the system. This is a great tool that can troubleshoot any problem that arises using these log files.

About the author

Taimoor Mohsin