Methods of payment Abuse

How to view logs in Linux

17.04.2021, 22:24

System administrators often need to review logs in a Linux operating environment. This is the first thing to do if there is a problem and the task is to fix it. The Linux operating system and running applications generate different types of messages that are logged in various log files.

Location of logs in Linux

Linux uses special software, files and directories to store log files. If you know which programs generate which logs, and more importantly, where these logs are located, you will be able to quickly solve any problems that arise with minimal loss of time. Next we will look at the main parts of the Linux logging system, the log files, and the utilities that can be used to view Linux logs.

All the basic Linux logs are located in the folder /var/log/ you can list the log files for your system using the ls command:

$ ls -l /var/log/

How to view logs in Linux

Next, let's look at the 20 different Linux log files located in the /var/log/ directory. Some of these logs are only found on certain distributions, for example, dpkg.log is only found on Debian based systems:

Просмотр Логов Линукс

Просмотр логов в Linux

Next, let's look at how to view these logs in the operating system.

Viewing logs in Linux

To view logs in the Linux operating environment, it is convenient to use several line command utilities. To do this, usually use any text editor, or a special utility. Most likely, you will need to get superuser rights to view logs in Linux. The list of commands most often used for this purpose is as follows:

  • cat;
  • head;
  • grep;
  • tail;
  • zcat;
  • zgrep;
  • zmore;
  • vi;
  • nano.

To view a scrollable log of /var/log/dmesg just execute:

$ less /var/log/dmesg

How to view logs in Linux

View real-time logs:

$ tail -f /var/log/dmesg

Open the dmesg log file:

$ cat /var/log/dmesg

View the first lines:

$ head /var/log/dmesg

Further output errors from /var/log/messages:

$ grep -i error /var/log/dmesg

How to view logs in Linux

You can also view logs in Linux using graphical utilities. The Logs program can be used to easily view and track system logs on a Linux laptop or personal computer.

How to view logs in Linux

You can install the program on any system with an X server installed. Also, any graphical test editor can be used to view logs.