All Linux systems create and store information about servers, boot processes, kernel, and applications in log files, which can be helpful for troubleshooting as it contains systems activity logs. The log files are stored in /var/log directory and its subdirectory. In this tutorial, we will learn how to view and monitor log files in CentOS8 using different ways. So, let’s get started.
It is the most commonly used command to view logs. To use this command –f is used to follow the content of the file, open up the terminal and type the following command:
# sudo tail –f /var/log/apache2/access.log
As log files are changed apparently. If you want to display a limited number of lines use –n and the number of lines you want to display, as shown below.
# sudo tail –n5 –f /var/log/apache2/access.log
This command will only display the last five lines of the log file, as shown below.
To view the live output of the file using –F with less command as shown below.
# sudo less –f /var/log/httpd/access_log
If you want to display multiple log files simultaneously use the multitail command. The name itself implies that it is used to view and monitor multiple log files. For this we need to install the package firstly. Use the following command to install the package in CentOS8.
# sudo dnf install –y multitail
After the installation is completed, it’s a time to display two log files simultaneously. For this use the use the following command.
# sudo multitail /var/log/httpd/access_log /var/log/httpd/error_log
In this tutorial, we learned how to view the log files using different ways, we also saw how to view multiple log files simultaneously using multitail command, how to display the limited number of lines.
Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…
ISPConfig is an open-source control panel that allows users to manage multiple servers from a…
As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…
Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…
Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…
phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…