1. Home
  2. Linux
  3. Check system logs on linux

How to check system logs on Linux

Want to access your system logs on Linux? All Linux system logs are stored in the log directory. Each one is an individual file, and everything is categorized and sorted based on each application.

System logs – Terminal

If you’ve had trouble with a particular program on your Linux PC or server, you’d navigate to the log directory and view all of the files inside.

Any user, root or otherwise, can access and read the log files /var/log/ directory. To get to /var/log/ launch a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T. Then, in the command-line window, use CD to change directories from the home folder (~/) to the system log directory.

cd /var/logs/

Once you’ve made it into the log directory on the system, you’ll need to make use of the LS command to view all of the individual sub-directories and files in /var/log/.

ls

LS will print out a complete list of all log files on the screen. From here, find a file you’d like to view and take note of the filename. Then, run the cat command to take a look at the contents of the log file.

sudo cat example_error_log

Or, if you need to view a log in a sub-directory, do:

cd name_of_program_folder

ls

sudo cat example_error_log

Copy error logs

For whatever reason, you may want to make a copy of a system log, for later reading outside of the /var/logs/ directory. To do this, you can make use of the cp command. For example, to copy a single error log file, do the following.

cd /var/log/

Then, create a folder to store the system logs on your system in the ~/Documents directory.

mkdir -p ~/Documents/system-logs/

Make a copy of your log file with:

cp example_error_log ~/Documents/

Alternatively, it is possible to make a copy of a log folder inside of the /var/log/ directory with cp and the “r” command-line switch. For example.

Note: in some cases, you may not be able to copy logs out of the /var/log/ directory without the use sudo.

cd /var/log/
mkdir -p ~/Documents/system-logs/
cp -r name_of_program_folder ~/Documents/system-logs/

View system logs via GUI

The command-line way of looking at system logs on Linux is efficient and fast. However, not everyone likes working with the command-line. If you want to keep track of your Linux system’s error logs but would prefer a GUI interface to do so, there are a few good GUI system log reading applications out there for you to choose from.

One of the easiest application to install and understand is Gnome Logs. It has lots of great features, including sorting errors by category (application, security, hardware,) the ability to export logs to a file, and even a search button.

Install Gnome Logs

To install Gnome Logs, open up a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T. Then, follow the instructions that correspond with your Linux operating system.

Ubuntu

sudo apt install gnome-logs

Debian

sudo apt-get install gnome-logs

Arch Linux

sudo pacman -S gnome-logs

Fedora

sudo dnf install gnome-logs

OpenSUSE

sudo zypper install gnome-logs

View error messages

Gnome Logs is pretty straightforward. Just open it up and instantly you’ll see the latest system logs printed on the screen, sorted by category.

When the Gnome Logs application opens, by default it starts up the latest error log file. If you need to view older log files, click the arrow button in the center of the window UI. Then, use the menu that appears to select the error log you wish to view manually.

View logs based on category

One of the best things about Gnome Logs is that it sorts error logs based on several category types. These categories are:

  • Important
  • All
  • Applications
  • System
  • Security
  • Hardware

To sort logs based on category, look to the left-hand sidebar. Then, click on the category you wish to view. Soon after, Gnome Logs will display only system logs with that specific tag.

Search logs

Need to quickly find an error and don’t have time to wade through dozens of log files? Try out the search feature!

To search system logs in the Gnome Logs, click on the magnifying glass icon. Then, write out your search query. Soon, the app should show you some results that relate to your keyword.

Export logs to file

Gnome Logs makes saving error logs to an external file incredibly easy. Here’s how it works.

Step 1: Select the log you wish to view with the Gnome Logs selection menu.

Step 2: Click on the export button to the right of the magnifying glass icon.

Step 3: Use the file browser to save the log file to your Linux system.