Candid photograph of a Linux server terminal with a soft olive-green glow against a dark slate background, conveying a calm technical atmosphere.

Step-by-step guides for system administrators — covering command-line basics, web server setup, and preparation material for technical interviews.

Browse Tutorials

Using Journalctl to Query and Filter Systemd Logs

Systemd’s journal collects messages from services, the kernel, the boot process, and many command-line programs in one searchable log. The journalctl utility turns that data into a practical troubleshooting tool for Linux administrators working on RHEL, CentOS, Fedora, and related distributions.

A good query reduces noise before you start interpreting events. Whether a web server in Sydney stops responding, a firewall rule behaves differently after a reboot, or a scheduled task fails overnight, journal filters can reveal when the problem began and which unit reported it. Administrators who want to strengthen their command-line skills can also browse these Linux command tutorials for related tools.

Reading Journalctl Output

Run journalctl without options to view the complete journal, usually beginning with the oldest available entries. The output includes a timestamp, hostname, process or unit name, priority, and message text. Press Space to move forward, b to move back, and q to exit the pager.

sudo journalctl

On many systems, the journal is readable only by root or members of groups such as systemd-journal. Use sudo when investigating server events, and remember that timestamps may use the system’s configured timezone. A host in Perth can therefore display different local times from an administrator working in Melbourne or Brisbane.

Filtering by Time and Boot

Time filters are among the fastest ways to reduce output. --since and --until accept dates, times, and relative expressions such as “1 hour ago” or “yesterday”.

sudo journalctl --since "2025-03-01 09:00" --until "2025-03-01 10:00"
sudo journalctl --since "30 minutes ago"
sudo journalctl --since yesterday

To inspect the current startup, use -b. Earlier boots receive negative indexes, so -b -1 shows the previous boot and --list-boots displays available boot IDs and time ranges.

sudo journalctl -b
sudo journalctl -b -1
sudo journalctl --list-boots

Selecting Services and Priorities

The -u option filters messages belonging to a systemd unit. This is useful for Nginx, SSH, NetworkManager, firewalld, and application services.

sudo journalctl -u nginx
sudo journalctl -u sshd --since today
sudo journalctl -u firewalld -b

Priority filtering helps isolate serious events. Levels range from emerg through debug; -p err displays errors and more severe messages, while -p warning..err selects a range.

sudo journalctl -p err -b
sudo journalctl -u nginx -p warning..err

Searching Messages Precisely

Use -k to display kernel messages, which is useful for storage, networking, drivers, and hardware faults. The short aliases -f and -n are also valuable: -f follows new entries, while -n 50 prints the latest 50 records.

sudo journalctl -k -b
sudo journalctl -n 50
sudo journalctl -u nginx -f

For text searches, pipe the output to grep. This works well for terms such as failed, timeout, denied, or an interface name. Structured fields provide more precise filtering: _PID, _UID, _COMM, _HOSTNAME, and _SYSTEMD_UNIT can be queried with field matches.

sudo journalctl -b | grep -i "failed"
sudo journalctl _SYSTEMD_UNIT=sshd.service
sudo journalctl _COMM=sudo --since today

Following Logs and Exporting Evidence

When restarting a service, follow its messages in a second terminal so that startup errors appear immediately.

sudo journalctl -fu nginx

For scripts and incident records, use --no-pager and a predictable output format. -o short-iso produces ISO-like timestamps, while -o json or -o json-pretty is suitable for processing with tools such as jq.

sudo journalctl -u nginx --since today --no-pager -o short-iso
sudo journalctl -u sshd -b -o json-pretty

Remote administrators often investigate through a VPN, particularly when managing systems outside a Sydney office or data centre. Network interruptions can make a live stream misleading, so save a bounded time range locally before comparing it with connection events; a general VPN performance guide also illustrates why latency and tunnel stability matter when reviewing remote activity.

Common Queries at a Glance

The following commands cover routine checks on Fedora and RHEL-family hosts.

Goal Command
View current boot sudo journalctl -b
Show previous boot sudo journalctl -b -1
Inspect one service sudo journalctl -u nginx
Show recent errors sudo journalctl -p err -b
Follow live messages sudo journalctl -f
Review a time window sudo journalctl --since "09:00" --until "10:00"
Display kernel events sudo journalctl -k

Journal retention depends on configuration and available disk space. Check usage with journalctl --disk-usage, and remove old entries only through an approved retention policy. Australian organisations may need to consider the Privacy Act 1988 when logs contain usernames, IP addresses, or customer information; keeping only necessary records supports both security and responsible data handling.

A Practical Troubleshooting Routine

Start with a narrow query, then widen it only when needed. These filters are useful during service incidents:

Before changing configuration, capture evidence in a readable form:

For persistent storage, inspect /etc/systemd/journald.conf and any files in /etc/systemd/journald.conf.d/. After changes, reload the daemon and verify that new entries are being retained. Documentation corrections or technical feedback can be sent through the contact page, while operational investigations should preserve the original timestamps and command options used.

On the next incident, run sudo journalctl -u nginx --since "15 minutes ago" -p warning..err first, then widen the time range if the failure is not visible.