$linuxjunkies
>

journalctl(1)

Query and display messages from the systemd journal.

UbuntuDebianFedoraArch

Synopsis

journalctl [OPTION]... [MATCHES]

Description

journalctl is used to query and display log messages recorded by systemd-journald, the system journal daemon. It can display logs from the entire system, specific services, or filtered by time, priority, and other criteria.

The journal stores structured log data in binary format, making it more powerful than traditional syslog while remaining efficient. By default, journalctl shows logs in reverse chronological order (newest first).

Common options

FlagWhat it does
-u, --unit=UNITshow logs for a specific systemd unit (service, socket, etc.)
-f, --followfollow journal in real-time, like tail -f
-n, --lines=NUMshow the last NUM lines (default 10 when used with -f)
-p, --priority=LEVELfilter by priority: emerg, alert, crit, err, warning, notice, info, debug
-b, --boot[=ID]show logs from current boot or specified boot ID
--since=DATETIMEshow entries not older than date; accepts formats like '2024-01-15 10:30:00' or 'yesterday'
--until=DATETIMEshow entries not newer than specified date and time
-o, --output=FORMAToutput format: short, short-iso, short-precise, json, cat (default is short)
-e, --pager-endjump to end of journal in the pager instead of showing the beginning
--no-pagerdo not pipe output into a pager
-x, --catalogaugment log lines with message explanations from the message catalog
-a, --allshow all fields including long data (without truncation)

Examples

show all logs from the nginx service

journalctl -u nginx.service

show the last 20 lines of SSH service logs

journalctl -u ssh.service -n 20

follow MySQL logs in real-time

journalctl -f -u mysql.service

show only ERROR and CRITICAL level messages from all services

journalctl -p err

show logs between two specific times

journalctl --since '2024-01-15 10:00:00' --until '2024-01-15 12:00:00'

show logs from the previous boot

journalctl -b -1

output logs as JSON and pipe to jq for parsing

journalctl -o json | jq .

show logs from the bash executable

journalctl /usr/bin/bash

Related commands