Skip to main content

journalctl: How to Read and Filter System Logs on Linux

On Linux systems that use systemd, journalctl shows you the system logs. It is the tool to use when a service fails or a boot goes wrong. This guide was written on November 27, 2026, and follows the manual pages for systemd 262 (development version).

What it does

While your computer runs, it keeps writing short notes about its work. It records when it starts, and it records when a program runs into a problem. These notes are called logs. On most modern Linux systems, a background program called journald gathers them in one place: the journal.

journalctl reads that journal for you. Think of the journal as the logbook at the front desk of a large building. Each event gets one line with the time and the room where it happened, and every room stands for one program on your computer.

journalctl works like the clerk at that desk. You might ask for only what happened in room 12 last night. The clerk finds those lines and skips everything else. The comparison stops working in one place: you ask with short typed codes, not with full sentences.

Debian, Ubuntu, Fedora, Arch, openSUSE and other popular Linux versions all keep this journal. It works on its own, with no setup from you.

Most people open the journal only when something breaks, and then it is the first place to look. A very simple example is journalctl -b. It shows the notes since the computer last started.

Back to top

How to use it

journalctl comes with systemd, so there is nothing to install. Any user can read their own logs. Reading all system logs takes root (for example with sudo) or membership in the systemd-journal, adm or wheel group.

To see the error messages from the previous boot:

sudo journalctl -b -1 -p 3

This lists entries of priority 3 (error), plus every more severe level, from the boot before the current one.

To follow a single service:

sudo journalctl -u ssh.service

This shows the SSH service log together with related systemd messages; on your distro the unit name may differ.

To watch new messages as they arrive:

sudo journalctl -n 20 -f

This prints the last 20 lines, then keeps adding new entries until you press Ctrl-C.

To limit the output to a time range:

sudo journalctl -S "2026-11-20 08:00:00" -U "2026-11-20 18:00:00"

Only entries between the two times appear; replace them with the date and times you need.

To search the message text:

sudo journalctl -g "usb"

This keeps only the entries whose message matches the pattern, and a lowercase pattern ignores case.

To list the boots the journal knows about:

sudo journalctl --list-boots

The result is a table with boot numbers, boot IDs, and the times of the first and last message of each boot.

To check how much disk space the logs take:

sudo journalctl --disk-usage

This reports the total size of all journal files, archived and active together.

Warning: This permanently deletes old log data. You cannot get these logs back after the command runs.

sudo journalctl --vacuum-time=2d

This deletes archived journal files older than two days; --vacuum-size= does the same job with a size such as 500M.

Three more options help in daily use. -k limits the output to kernel messages from the current boot. -r puts the newest entries at the top. And --no-pager prints everything at once instead of opening the less pager.

Back to top

How it works

Where the data comes from

systemd-journald gathers messages from several places: kernel messages, messages sent through the libc syslog(3) call, and structured messages from the native Journal API. It also collects the stdout and stderr of service units, as well as kernel audit records. The journal is structured and indexed. Every entry carries metadata fields, which the systemd.journal-fields(7) man page lists.

Matches and filters

Any field can serve as a filter with FIELD=VALUE. When you match on different fields, journalctl combines them with AND. Matches on the same field are combined with OR, and a separate + between terms also means OR. For example, journalctl _PID=1234 shows the messages of one process. If you give an absolute path to a program, journalctl turns it into an _EXE= match.

-p takes either one level or a range written as FROM..TO. The levels run from emerg (0) to debug (7), and a single level also covers all more severe ones. -g uses PCRE regular expressions. A pattern in all lowercase is case-insensitive unless you add --case-sensitive.

Output formats

Use -o to change the format. short is the default. Other choices include short-iso, short-precise, verbose, json, json-pretty, cat and export. The -x option adds help texts to some entries, although the man page advises against it for bug report attachments. The -e option jumps to the end of the output, and it implies the current boot and --lines=1000.

Storage and persistence

Where logs live depends on the Storage= setting in journald.conf:

  • volatile: in memory, under /run/log/journal.
  • persistent: on disk, under /var/log/journal. Early in boot, or if that path is not writable, journald uses /run/log/journal.
  • auto: persistent only if /var/log/journal exists.
  • none: logs are discarded, but forwarding still works.

Distros pick different defaults, so check yours. Without /var/log/journal, logs are lost at reboot. At boot, journald starts in volatile mode, and systemd-journal-flush.service later flushes the data to disk. If you want to keep logs across reboots, make them persistent by running these commands as root:

sudo mkdir -p /var/log/journal
sudo systemd-tmpfiles --create --prefix /var/log/journal

The first command creates the journal directory; the second uses systemd-tmpfiles to prepare it for journald.

One more detail: the --user option works only when persistent logging is on.

Configuration and limits

Settings go in /etc/systemd/journald.conf, with drop-in files in /etc/systemd/journald.conf.d/. Systemd applies them in filename order, and the last one wins. By default, SystemMaxUse= is 10% of the file system and SystemKeepFree= is 15%, each capped at 4G. Whichever limit is smaller applies. Data objects larger than 512 bytes are compressed by default. MaxRetentionSec= defaults to 0, so journald does not delete logs by age. ForwardToSyslog= is off by default.

--vacuum-size=, --vacuum-time= and --vacuum-files= remove only archived files, and you can combine them. For other maintenance there are --flush, --rotate and --sync.

Integrity and other sources

Forward Secure Sealing uses keys you create with --setup-keys; --verify then checks the journal. The default key interval is 15 minutes. To read logs from other places, use -D for a directory, -i for a file, -m to merge, -M for a machine, or --namespace. Not every option is equally old: the man page says -g arrived in systemd 237.

Back to top

Sources

  1. journalctl(1) manual page — man7.org
  2. systemd-journald.service(8) — freedesktop.org
  3. journald.conf(5) — freedesktop.org
  4. journalctl (tldr page) — tldr-pages on GitHub
Back to top
Peter Martin
Linux admin, PHP dev and Joomla specialist

Open-source enthusiast since 2005 and co-founder of Linux Nijmegen (Netherlands), passionate about solving technical challenges and sharing knowledge.

Frequently asked questions

journalctl is a tool that reads the system logs on Linux systems using systemd. It helps you understand why a service failed or what happened during a boot. It reads logs collected by journald, which stores notes about computer events.

journalctl -b shows the entries from the computer’s last boot. This is a simple way to quickly review what happened during the previous startup process and identify any potential issues.

journalctl allows you to filter logs based on various criteria. You can use codes to specify a time range or focus on a particular program, like showing only messages from a specific service.

The systemd-journald service collects messages from various sources, including kernel messages, libc syslog calls, and structured messages from service units. This data is then indexed and stored in the journal.