view linux log files

How to View Linux Log Files

Linux uses various log files to store information about boot processes, applications & other processes. They are all plain text files that you can open in any text editor. Viewing log files is necessary in case of bugs or performance issues. In this article, we will learn how to view Linux log files. All log files in Linux are stored in /var/log and are generated by syslogd and rsyslogd.


How to View Linux Log Files

Here are the steps to view Linux log files.


1. Log into Linux

Log into Linux as root user. You need root privileges to be able to view log files.


2. Go to /var/log

Open terminal and run the following command to go to /var/log file.

$ cd /var/log


3. List all log files

Run ls command to view all log files in it. You will see files like kern.log and boot.log. You can use less command to view any log file.

$ sudo less [log file name here].log

Here is an example.

$ sudo less kern.log

Log files are large and it can be time consuming to scroll through the file. Here are some handy utilities to help you get the job done.

  • zcat – Displays contents of logfile.gz
  • zmore – See log file in pages, without decompressing the files
  • zgrep – Search inside a compressed file
  • grep – Find all occurrences of a search term in a file or filter a log file
  • tail – Output last few lines of files
  • head – View beginning of text files

System logs are the most important log files used by every Linux system. Here are the different system logs you should know.

  • var/log/boot.log: System Boot log (stores all information related to booting operations)
  • /var/log/auth.log: Auth logs (stores all authentication logs, including successful and failed attempts)
  • /var/log/httpd/: Apache access and error logs
  • /var/log/mysqld.log: MySQL database server log file
  • /var/log/debug: Debug logs (stores detailed messages related to debugging and is useful for troubleshooting specific system operations)
  • /var/log/daemon.log: Daemon logs (contains information about events related to running the Linux operation)
  • /var/log/maillog: Mail server logs (stores information related to mail servers and archiving emails)
  • /var/log/kern.log: Kernel logs (stores information from the Ubuntu Linux kernel)
  • /var/log/yum.log: Yum command logs

Apart from the above commands there are many GUI tools to view system logs such as System Log Viewer & Xlogmaster.

In this article, we have learnt about the different system logs maintained by Linux, and how to read them.

Also read:

How to Convert Files to UTF-8 Encoding in Linux
How to Set or Change Hostname in Linux
How to Convert Webpage to PDF in Linux
How to Find & Remove Duplicate Files in Linux
How to Shutdown/Reboot Remote Linux System

Leave a Reply

Your email address will not be published. Required fields are marked *