Linux Command Reference ยท Systemd and Logging (Read-Only)
journalctl filters
Narrow the systemd journal with journalctl: filter by unit, priority, boot, time range, process and fields, combine filters and output formats such as json.
The systemd journal can hold millions of entries, so journalctl is mostly a filtering tool. Every option below narrows the stream; filters of different kinds are combined with AND, so -u nginx -p err --since today means "nginx, at error level or worse, since midnight".
Read the output with the same habits as any log: filter first, then page, then search. This page lists the filters you will use constantly and how they combine. The sandbox has no journal, so the real commands are read-only; the examples run the same ideas against a sample log with awk and grep.
journalctl -u nginx -p warning --since "1 hour ago" journalctl -b -1 -p err journalctl _SYSTEMD_UNIT=sshd.service -o json-pretty -n 1
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
journalctl [OPTIONS] [MATCHES]
| Name | Description |
|---|---|
-u UNIT |
Only messages from that unit; repeat the option for several units (OR). |
-p LEVEL |
Priority filter: a name or number (0 emerg to 7 debug). -p err means 3 and more severe; -p warning..err is a range. |
-b [N] |
Messages from a boot: -b is the current one, -b -1 the previous. --list-boots shows them. |
--since, --until |
Time window: "2026-03-01 09:00", yesterday, today, "2 hours ago", -30min. |
-n N, -r |
Show the last N entries; -r prints newest first. |
-f |
Follow new entries as they arrive, like tail -f. |
-k |
Kernel messages only (the same source as dmesg). |
-g PATTERN |
Keep entries whose message matches a regular expression. |
-o FORMAT |
Output: short, short-iso, verbose, json, json-pretty, cat (message only). |
FIELD=value |
Match a journal field exactly, such as _PID=812, _UID=1000, _COMM=sshd, SYSLOG_IDENTIFIER=myapp. |
--no-pager, -x, -e |
Do not page; add explanatory help texts; jump to the end of the pager. |
--disk-usage, --vacuum-time=2weeks |
Show how much space the journal uses, or delete old entries (root). |
Returns: 0 on success. With -g or filters that match nothing it prints -- No entries -- and still exits 0 (newer versions may exit 1 for -g with no match).
Usage notes
- Different filters AND, repeated matches of the same field OR.
_COMM=sshd _COMM=cronshows both programs; adding-p errthen restricts both. - Permissions. Normal users see only their own entries unless they are in the
systemd-journal,admorwheelgroup; usesudootherwise. - The journal may be volatile. Unless
/var/log/journal/exists (orStorage=persistentis set), logs live in/runand vanish at reboot, which is why-b -1may say "no entries". - Time zones. Times print in the local zone; add
--utcto compare machines. Timestamps without a zone in--sinceare local time. - Machine-readable output.
-o jsongives one JSON object per line, ideal forjq;-o catstrips everything but the message for easygrep. - Find which fields exist with
-o verbose -n 1, then filter on any of them. -p errincludes worse levels. It is a threshold, not an exact match. See Log priorities.- Do not pipe the live journal to
grepfor what-gor-ucan do; the built-in filters use the journal's indexes and are far faster.