journalctl Command Guide for Reading the systemd Journal
journalctl queries the systemd journal — the single binary log store for every service, the kernel, and your login sessions — and it filters by time, unit, and priority better than any text log ever could.
What is journalctl, and Why Use It?
On a modern Linux system, logs do not only live in /var/log as text files. systemd keeps its own structured log store — the journal — holding messages from every service, the kernel ring buffer, boot messages, and user sessions. journalctl is the tool that reads it. Because the journal is indexed by unit, time, and priority, you can ask questions like “show me only nginx failures in the last hour” and get an answer in milliseconds, instead of grepping through megabytes of text.
Why Learn journalctl?
- It is where the answer actually is — service failures, boot problems, and crash traces land here first.
- Time filtering is exact — “since yesterday at 3pm” is a flag, not a hunt.
- It reads binary and text logs alike —
journalctlandtail -f /var/log/syslogboth work; the journal is the more reliable one. - It survives reboots — persistent journals keep history across restarts.
- One command replaces a dozen greps —
journalctl -u ssh -p erris not something a text log can do.
When Should You Use journalctl?
Use it whenever a systemd service misbehaves, a machine rebooted unexpectedly, or you need to see what the kernel said during boot. Reach for the text logs when you are chasing something a service wrote to a file directly, or on a system with no systemd.
1. The Basics
Read everything, oldest first:
journalctl
Read the most recent lines, newest last:
journalctl | tail -20
Or let journalctl do the paging:
journalctl --no-pager | tail -20
The flags you will use constantly
| Flag | Meaning |
|---|---|
-n 20 | Show the last 20 lines |
-f | Follow, like tail -f |
-k | Kernel messages only |
-u NAME | Only this service (unit) |
-p err | Priority err and above |
--since / --until | Time window |
-b | Current boot only |
-x | Add explanatory text for the message |
-xis the most underrated flag in this section. It attaches a human explanation to cryptic messages and frequently tells you the actual cause.
2. Filter by Service
Every systemd service is a unit. Filter to one:
journalctl -u nginx
Combine with line count and follow:
journalctl -u nginx -n 50 --no-pager
journalctl -u nginx -f
Check whether a unit exists
systemctl list-units --type=service --state=running
Example of a service that failed:
journalctl -u nginx -p err
-- Logs begin at Mon 2026-11-30 09:14:22 UTC, end at Sat 2026-12-05 11:02:41 UTC. --
Dec 05 10:47:03 web-01 nginx[812]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Dec 05 10:47:03 web-01 systemd[1]: nginx.service: Failed with result 'exit-code'.
That output names the problem exactly: something already holds port 80.
3. Filter by Time
Time filtering is where the journal beats text logs outright.
journalctl --since "1 hour ago"
journalctl --since today
journalctl --since "2026-12-01" --until "2026-12-02"
journalctl --since "2026-12-05 09:00" --until "2026-12-05 10:00"
journalctl --since yesterday -u ssh
Time formats that work
| Format | Example |
|---|---|
| Relative | "1 hour ago", "2 days ago" |
| Calendar day | today, yesterday, tomorrow |
| Full date | "2026-12-05" |
| Date and time | "2026-12-05 09:30:00" |
| Clock only | "09:30:00" (today) |
Quote anything with a space in it.
--since 1 hour agofails;--since "1 hour ago"works.
4. Filter by Priority and Boot
Priority
Messages carry levels from emerg (0) to debug (7). Show a floor:
journalctl -p err # errors and worse
journalctl -p warning # warnings and worse
journalctl -p 3 # numeric form of err
Boot
Every restart gets its own log:
journalctl -b # this boot only
journalctl -b -1 # the previous boot
journalctl --list-boots
IDX ab12cd34ef567890 Mon 2026-12-01 08:12:03 UTC—Mon 2026-12-01 09:40:11 UTC
IDX 0 cd34ef567890ab12 Mon 2026-12-01 09:41:02 UTC—Sat 2026-12-05 11:03:44 UTC
The previous boot is where you find out why the machine restarted:
journalctl -b -1 -p err --no-pager
5. Kernel Messages and Disk Usage
The kernel log is available through the journal, so you do not need a separate tool for most cases:
journalctl -k
journalctl -k -b
journalctl -k -p err
This is the same data as dmesg, but with time filtering attached.
How much disk is the journal using?
journalctl --disk-usage
Archived and active journals take up 412.3M in the file system.
Trim it
sudo journalctl --vacuum-time=7d # keep 7 days
sudo journalctl --vacuum-size=200M # keep at most 200M
sudo journalctl --vacuum-files=5 # keep 5 files
On a small server, journal growth is a real cause of a full disk.
--vacuum-sizeis the safe first move before you go deleting anything else.
6. Output Formats
Plain text is the default, but the journal stores structured data:
journalctl -u nginx -o json-pretty | head -20
journalctl -o short-monotonic -n 10
journalctl -o verbose -u ssh -n 1
JSON is the right choice when a script needs the fields:
journalctl -u nginx --since "10 min ago" -o json | grep -c '"err"'
Export for a bug report:
journalctl -u nginx --no-pager > nginx-log.txt
Common Pitfalls
Assuming the journal is persistent by default. Many distros keep it in RAM (/run/log/journal), which means everything is lost on reboot. Check and fix:
journalctl --header | grep -i storage
sudo mkdir -p /var/log/journal
sudo systemctl restart systemd-journald
Forgetting quotes around time values.
journalctl --since 1 hour ago
# Invalid timestamp: 1 hour ago
journalctl --since "1 hour ago" # works
Running without sudo on a restricted system. Some setups limit which journals an unprivileged user can read; you may see fewer entries than expected.
Searching for a message that is not there. If a service logs to a file rather than syslog, it is not in the journal. Check its own output first.
Using -f and expecting it to exit. journalctl -f follows forever, like tail -f. Press Ctrl+C to stop it.
Reading the journal after a vacuum. --vacuum-* deletes permanently. There is no undo.
Related Pages
| Page | Relationship |
|---|---|
| dmesg | Kernel ring buffer; journalctl -k reads the same data with time filtering |
| var-log | The classic text logs, and how they relate to the journal |
| uptime | Confirms whether a reboot happened, which boot you are on |
| vmstat | Shows the load and memory state behind a slow-service report |
| text-processing README | grep, awk, and sed for post-filtering the output |
journalctl Cheatsheet
| Command | Does |
|---|---|
journalctl | Everything, oldest first |
journalctl -n 20 | Last 20 lines |
journalctl -f | Follow live |
journalctl -u NAME | One service |
journalctl -u NAME -p err | Errors from one service |
journalctl -k | Kernel messages |
journalctl -b | Current boot only |
journalctl -b -1 | Previous boot |
journalctl --list-boots | List recorded boots |
journalctl --since "1 hour ago" | Time window |
journalctl -x | Add explanations |
journalctl --disk-usage | Space used |
sudo journalctl --vacuum-size=200M | Trim the journal |
journalctl -o json-pretty | Structured output |
When a service misbehaves, the journal is the first place the answer is.