// learn Β· linux Β· rhcsa Β· 9 min

Logs with journalctl.

systemd collects every service's output into one structured journal β€” then journalctl lets you slice it by unit, time, and priority. Learn the handful of filters that turn a wall of logs into the three lines that actually matter.

Logs with journalctl animated tutorial. The systemd journal, filtering by unit (-u), priority (-p), and time (--since/--until), following live logs (-f), listing boots (-b), and configuring a persistent journal. RHCSA EX200 ready.
// logs with journalctl

systemd funnels every service's output into one structured, queryable journal. Watch each filter narrow a wall of logs down to the lines that matter.

// before you start
you should know
  • Β·Comfortable starting/checking services with systemctl
  • Β·Helpful: the systemd targets lesson (units, services)
  • Β·Know roughly what stdout/stderr are
by the end you'll

Filter the journal by unit, priority, and time; follow logs live; inspect previous boots; and make the journal persistent.

pace: 9 minutes

journalctl β€” step 1 / 6 Β· the journal
$journalctl
09:14:02hostsshd[1201]:Accepted publickey for alice from 10.0.0.5info
09:15:33hostnginx[890]:200 GET /info
09:16:01hostnginx[890]:502 Bad Gateway /apierr
09:17:45hostkernel:usb 1-2: USB disconnectinfo
09:18:10hostsshd[1201]:Failed password for root from 198.51.100.7warning
09:20:00hostsystemd[1]:Started Daily apt timerinfo
09:21:30hostnginx[890]:500 Internal Server Error /checkouterr
09:22:15hostkernel:Out of memory: Killed process 890 (nginx)crit

The journal β€” one structured log for everything

On systemd systems, every service's stdout/stderr and every kernel message lands in ONE place: the journal. It's binary and indexed (not plain text), so you can query it by field β€” which unit, which priority, which time β€” instead of grepping scattered files. `journalctl` with no arguments prints all of it, oldest first.

$journalctl
$journalctl -e
$journalctl -n 20
// key insight

The journal is structured, not plain text. Every entry carries fields β€” unit, priority, PID, timestamp, and more β€” so journalctl filters are exact and composable. The real skill isn't reading logs, it's stacking filters: journalctl -u nginx -p err --since "1 hour ago" turns thousands of lines into the three that explain the outage.

// exam-ready Β· the journalctl flags that matter
$journalctl -u UNIT
$journalctl -p err
$journalctl --since "09:18"
$journalctl --until "10:00"
$journalctl -f
$journalctl -e
$journalctl -n 50
$journalctl -r
$journalctl -b / -b -1
$journalctl --list-boots
$journalctl -k
$journalctl _PID=1234
$journalctl -o json-pretty
$journalctl --disk-usage
$journalctl --vacuum-time=2weeks
$/etc/systemd/journald.conf
// check yourself
4 quick questions
Q1

You want to see only the logs for the nginx service. Which command?

Q2

`journalctl -p err` is running. A 'warning' message appears. Is it shown?

Q3

A server crashed and rebooted. You want the logs from BEFORE the reboot. What do you run β€” and what might prevent it from working?

Q4

You want to watch a service's logs live while you reproduce a bug. Best command?

These aren't graded β€” they're just for active recall, which is what actually makes the lesson stick.

🌳
// what produces these logs

systemd targets & units

Every line in the journal comes from a unit. Understand how systemd starts and supervises those services, and the `-u` filter suddenly makes total sense.

open β†’

Read this lesson as text6 chapters Β· quiz answers

  1. 01The journal β€” one structured log for everything

    On systemd systems, every service's stdout/stderr and every kernel message lands in ONE place: the journal. It's binary and indexed (not plain text), so you can query it by field β€” which unit, which priority, which time β€” instead of grepping scattered files. journalctl with no arguments prints all of it, oldest first.

    • $ journalctl β€” everything, oldest β†’ newest
    • $ journalctl -e β€” jump to the end (newest)
    • $ journalctl -n 20 β€” last 20 lines only
  2. 02Filter by unit β€” -u

    Almost every investigation starts here: show only one service's logs. journalctl -u nginx (or nginx.service) hides everything else. Combine units by repeating -u. This is the single most useful journalctl flag β€” pair it with systemctl status nginx, which shows the last few journal lines for the unit inline.

    • $ journalctl -u nginx β€” just nginx
    • $ journalctl -u nginx -u sshd β€” two units
    • $ systemctl status nginx β€” status + last log lines
  3. 03Filter by priority β€” -p

    Logs have syslog priorities from 0 (emerg) to 7 (debug). LOWER is more severe. journalctl -p err shows err and everything more severe (crit, alert, emerg) β€” it hides info, notice, debug noise. Great for 'just show me the problems'. The warning at 09:18 is NOT shown because warning (4) is less severe than err (3).

    • $ journalctl -p err β€” err and worse (≀3)
    • $ journalctl -p warning β€” warning and worse (≀4)
    • $ journalctl -u nginx -p err β€” combine: nginx errors only
  4. 04Filter by time β€” --since / --until

    Narrow to a window. --since and --until accept absolute times ('2026-05-27 09:18'), clock times ('09:18'), or human phrases ('1 hour ago', 'yesterday'). Here --since 09:18 drops everything before 09:18 β€” exactly what you want when you know roughly when the incident started.

    • $ journalctl --since "09:18" β€” from 09:18 onward
    • $ journalctl --since "1 hour ago" β€” relative time
    • $ journalctl --since today --until "12:00" β€” a bounded window
  5. 05Follow live β€” -f

    journalctl -f tails the journal live, printing new entries as they arrive β€” the journal equivalent of tail -f. Combine with -u to watch one service while you reproduce a bug: journalctl -u nginx -f. Ctrl-C to stop. This is what you leave running in one terminal while you poke the service in another.

    • $ journalctl -f β€” follow everything live
    • $ journalctl -u nginx -f β€” follow one service
  6. 06Boots and persistence β€” -b

    journalctl -b shows only the current boot; -b -1 the previous boot β€” invaluable for diagnosing a crash that required a reboot. journalctl --list-boots lists them. By default many systems keep the journal in RAM (lost on reboot). To make it survive, create /var/log/journal (or set Storage=persistent in journald.conf) β€” then -b -1 actually has something to show.

    • $ journalctl -b β€” current boot only
    • $ journalctl -b -1 β€” previous boot (crash diag)
    • $ journalctl --list-boots β€” all recorded boots
    • $ mkdir -p /var/log/journal β€” make the journal persistent
    • $ journalctl --disk-usage β€” how big is it?

Quiz β€” answers

You want to see only the logs for the nginx service. Which command?
β†’journalctl -u nginx-u filters by systemd unit and is the right tool β€” it matches the unit field exactly, not just any line containing 'nginx'. grep nginx would also catch unrelated lines that happen to mention nginx, and miss structured fields.
journalctl -p err is running. A 'warning' message appears. Is it shown?
β†’No β€” priorities go 0 (emerg) … 7 (debug), LOWER is more severe. err is 3, warning is 4, so -p err shows only ≀3 (err and worse).Lower number = more severe. -p err (3) includes err, crit, alert, emerg β€” but NOT warning (4), notice (5), info (6), or debug (7). It's a 'show me at least this bad' filter.
A server crashed and rebooted. You want the logs from BEFORE the reboot. What do you run β€” and what might prevent it from working?
β†’journalctl -b -1 β€” but if the journal isn't persistent (no /var/log/journal), the previous boot's logs were lost on reboot.-b -1 selects the previous boot. But if journald is volatile (RAM-only, the default on some systems), those logs vanished at reboot. Create /var/log/journal (or set Storage=persistent) ahead of time so post-crash forensics is possible.
You want to watch a service's logs live while you reproduce a bug. Best command?
β†’journalctl -u myservice -f-f follows the journal live (like tail -f), and -u myservice scopes it to one unit. Leave it running in one terminal and trigger the bug in another to see exactly what the service logs in real time.
// more in linux

keep going β€” these pair well with what you just learned.

see all linux β†’

See also

back to RHCSA trackall lessons