The syslog file contains the log messages of different software applications and administrative tasks of the computer. Monitoring and keeping track of the log messages helps the user to determine the root cause of the computer issues.
For example, if the user is running multiple applications at the same time and one crashes unexpectedly due to a shortage of memory. Then, the reason behind the crashing or the interruption of the application can be viewed from the syslog file.
The ways to view the syslog file and other information related to the syslog file have been explained in this blog. The blog will follow the outline:
- Where is the syslog in Debian
- Why is it Required to View the syslog on Debian
- What are the Ways to View syslog on Debian
- Method 1: View syslog Using the less Command on Debian
- Method 2: View syslog Using the dmesg Command on Debian
- Method 3: View syslog Using the tail Command on Debian
- Method 4: View syslog Using the cat Command on Debian
- Method 5: View syslog Using the journalctl Command on Debian
- Method 6: View syslog Using the gnome-system-log on Debian
Let’s start the blog by exploring the location where the syslog is located on Debian.
Where is the syslog in Debian?
The syslog and other log files are located in the /var/log directory and to validate this, launch the terminal and navigate to the /var/log directory by running the command:
$ cd /var/log
List down the contents of the /var/log directory with the command:
Different types of logs including the dpkg log, kernel logs, and authorization logs have been displayed on the screen. We are running Debian on a virtual machine, therefore, we are seeing the vbox logs instead of system logs.
Why is it Required to View the syslog on Debian?
To view the syslog on Debian is important because it keeps the record of the log messages of the activity running on the computer. Important reasons for viewing the syslog are:
- To find out the error and troubleshoot them
- To find the overall health of the system
- To ensure the security of the system by ensuring no unfortunate application is being run
- To find out the system performance and trends of its performance
What are the Ways to View syslog on Debian?
Different ways to view the syslog on Debian have been demonstrated with the examples in the next sections.
Method 1: View syslog Using the less Command on Debian
The first command line tool that can be used to view the contents of the syslog file is by using the less command. This command will provide ease to users by displaying only one screen content at a single time.
To view the syslog using the less command, use the following command in the terminal:
$ less /var/log/syslog
The contents of the syslog will be displayed and to find more about the usage of the less command in Debian, open the mentioned post.
Method 2: View syslog Using the dmesg Command on Debian
Another method to view the syslog is by using the dmesg command. This command will primarily display all the log messages of the Kernel. These messages will also display the syslog messages.
To view the syslog on Debian using the dmesg command, run the command:
The output will display the entire log messages from the kernel ring buffer. Additionally, to learn more about the usage of the “dmesg”, open the post.
Method 3: View syslog Using the tail Command on Debian?
The tail command is used to view the last few lines of the syslog file by running the command:
$ tail /var/log/syslog
Additionally, to monitor the next coming log messages in the syslog file, use the “f” option of the “tail” command:
$ tail -f /var/log/syslog
The usage of the tail command in Debian and other Linux distributions has been explained in the following article.
Method 4: View syslog Using the cat Command on Debian
The cat command can also be used to display the contents of the syslog file and to use the cat command for displaying the syslog’s contents, run the command:
$ cat /var/log/syslog
Method 5: View syslog Using the journalctl Command on Debian
Also, the syslog file can be viewed by using the journalctl command. It displays the recent entries of the syslog file with the execution of the command:
To monitor the entries of the syslog on a real-time basis, run the command:
$ journalctl -f
Moreover, to display the detailed message of the syslog file, execute the command:
$ journalctl -o cat
Lastly, to display the log entries only of the current boot session, execute the command:
$ journalctl -b
This is the usage of the journalctl command for viewing the syslog file on Debian.
Method 6: View syslog Using the gnome-system-log on Debian
Various GUI-based methods can also be used to view the syslog on Debian 12. In this guide. The most popular GUI tool, “gnome-system-log” is used to view the contents of the syslog file.
First, install the “gnome-system-log” software application by running the command:
$ sudo apt install gnome-system-log -y
Once the installation is completed with the successful execution of the command, then launch the installed application:
Now click on the “dpkg.log” as shown below to view its contents:
To view the syslog on Debian, open the terminal and view the contents of the “/var/log/syslog” file. The cat, less, and tail commands can be used for this. Also, the dmesg and journalctl commands are used to view the contents of the syslog on Debian 12.
The syslog file contains all the log messages of the system and running software applications. To view this file is useful for troubleshooting the errors and also to monitor the system running activities.
This blog has explained different methods including the command-line and GUI-based to view the contents of the syslog file.