Computing and the Command Line

Reading Logs with journalctl

On a systemd system, the kernel, every service, and every program systemd runs log to one place, the journal, kept across reboots in /var/log/journal. journalctl reads it: by boot (-b, -b -1, --list-boots), by unit (-u), by priority (-p err), by time (--since, --until), live (-f), the kernel (-k), the newest (-e, -n, -r), with explanations (-x). Who can read it, how much disk it uses, and a worked example of tracking down why something failed.

  • 6 min
  • 12 steps
  • 2 questions
  • Lesson 51 of 80

In this lesson

  1. One log for everything
  2. Who can read it
  3. This boot and the last
  4. One service
  5. Only the problems
  6. By time
  7. As it happens
  8. More useful options
  9. A worked example
  10. How much space it takes
  11. Your turn
  12. So

One log for everything

Windows has the Event Viewer; Linux used to have a folder of separate text files. On systemd systems there’s the journal: the kernel, every service, and the output of every program systemd starts all go to one service, systemd-journald, which stores them with the time, the unit, the priority, and the boot they came from 1 2.

By default it’s kept on disk under /var/log/journal, so logs survive reboots 3. That matters most when something went wrong and you had to restart.

journalctl reads it. With no options it shows everything, oldest first, in a pager 1. The pager is less: Space for the next page, G for the end, / to search, q to quit.

Left, sources: the kernel, system services, your services and timers, and the output of anything systemd runs, all feeding systemd-journald, which stores the journal in /var/log/journal, kept across reboots. Each entry records the time, the unit, the priority, and which boot it came from. Members of the adm group may read the whole journal without sudo; check with groups. Right, journalctl filters: -b this boot; -b -1 the boot before; -u ssh one unit; -p err errors and worse; --since "1 hour ago" a time range; -f follow new lines; -k kernel messages; -e jump to the end; -x add explanations; and an example, journalctl -b -1 -p err. Bottom, priorities from syslog: 0 emerg, 1 alert, 2 crit, 3 err, 4 warning, 5 notice, 6 info, 7 debug; -p err shows 0 to 3.
One journal for everything; journalctl narrows it down. Credit: StudyCorner diagram · CC BY 4.0 · Source

Who can read it

Your own user services’ logs are always readable by you. The system journal is readable by root and by members of the groups adm, systemd-journal, and wheel 1. Check with groups: if adm is listed, journalctl works without sudo; otherwise use sudo journalctl.

This boot and the last

me@garden-laptop:~$ journalctl -b
me@garden-laptop:~$ journalctl -b -1
me@garden-laptop:~$ journalctl --list-boots

-b limits it to the current boot; -b -1 to the one before, -b -2 the one before that 1. --list-boots shows a numbered table of the boots in the journal with their first and last times 1. After a crash or freeze, the previous boot is where the clues are.

Quick check

Your laptop froze and you had to hold the power button. After restarting, how do you see errors from the boot that froze?

One service

me@garden-laptop:~$ journalctl -u ssh
me@garden-laptop:~$ journalctl -b -u cups

-u shows one unit’s messages 1. The few lines at the bottom of systemctl status are the same thing, cut short; journalctl -u gives the whole story.

Only the problems

Every message has a priority, the standard syslog levels from 0 (emerg) to 7 (debug): emerg, alert, crit, err, warning, notice, info, debug 1. -p shows that level and everything more serious:

me@garden-laptop:~$ journalctl -b -p err
me@garden-laptop:~$ journalctl -b -1 -p warning

-p err is levels 0 to 3 1. Some errors on every boot are normal, from hardware or features you don’t use. What you’re looking for is what’s new or what lines up with the trouble.

By time

me@garden-laptop:~$ journalctl --since today
me@garden-laptop:~$ journalctl --since "1 hour ago"
me@garden-laptop:~$ journalctl --since "2026-10-05 14:00" --until "2026-10-05 14:30"

--since and --until take a date and time like 2026-10-05 14:00, the words yesterday, today, and now, or a relative time like "1 hour ago" 1.

As it happens

me@garden-laptop:~$ journalctl -f
me@garden-laptop:~$ journalctl -f -u ssh

-f follows the journal, printing new lines as they arrive until Ctrl-C 1. Start it in one terminal, then reproduce the problem in another, plugging in the device or trying the connection, and watch what gets logged. The manual’s own example is following a web server, journalctl -f -u apache 1.

Quick check

Which command shows a service’s log lines live, as they’re written?

More useful options

  • -k: only kernel messages (hardware, drivers, USB devices), for this boot unless you say otherwise 1. journalctl -k -b -1 is the previous boot’s kernel log.
  • -e: open the pager at the end, the newest messages 1.
  • -n 50: just the last 50 lines; -r: newest first 1.
  • -x: add explanation text to messages where the journal’s catalog has one 1.
  • --user: your own user services’ logs (lesson 3).

They combine: journalctl -b -1 -p err -u ssh is errors from SSH during the previous boot.

A worked example

Say the printer stopped working.

  1. Is the service healthy? systemctl status cups. If it’s failed, the last lines may already say why.
  2. What did it log? journalctl -b -u cups -e jumps to its newest messages this boot.
  3. Did the hardware show up? journalctl -f -k, then unplug and replug the USB cable: the kernel logs the device arriving, or doesn’t.
  4. Anything else complaining? journalctl -b -p err --since "10 minutes ago".

Copy the exact error message into a web search with your Ubuntu version. Exact messages find answers; descriptions like “printer broken” don’t.

How much space it takes

me@garden-laptop:~$ journalctl --disk-usage
me@garden-laptop:~$ sudo journalctl --vacuum-time=4weeks

--disk-usage shows the total size of the journal files; --vacuum-time deletes archived ones older than the time given 1. journald limits its own size by default, to at most 10% of the file system and never more than 4 GB, so this is rarely needed; the limits can be changed in /etc/systemd/journald.conf 3.

Some programs still write their own text logs under /var/log, such as dpkg.log and the unattended-upgrades folder from the last module. ls /var/log shows what’s there, and less or tail -f reads them.

Your turn

Exercises

  1. groups: can you read the system journal without sudo?
  2. journalctl --list-boots. How many boots does the journal remember?
  3. journalctl -b -p err. What errors did this boot log? Pick one and look it up.
  4. journalctl -b -1 -p warning | tail: the end of the previous boot, warnings and worse.
  5. Run journalctl -f -k and plug in a USB stick. What did the kernel log? Ctrl-C to stop.
  6. journalctl -u cron --since today (or -u systemd-journald): what has it done today?
  7. journalctl --disk-usage.
Answers
  1. If adm (or systemd-journal) appears in the list, yes.
  2. Common harmless ones mention firmware, Bluetooth, or ACPI. Worry about errors that appear only since the trouble started.
  3. Lines about a new USB device, its maker and model, a new disk such as sdb, and its partitions.
  4. For cron, lines like (root) CMD (...) for each job it ran.

So

The journal collects every log, from the kernel, services, and programs systemd runs, in /var/log/journal, kept across reboots. journalctl reads it, and its filters combine: -b this boot, -b -1 the last, -u name one unit, -p err errors and worse, --since and --until for a time range, -f to follow live, -k for the kernel, -e to jump to the end. Members of adm can read it without sudo. Start with systemctl status, then the unit’s journal, then the kernel, and search for exact error messages.

Lesson complete

Nice work.

1day streak
0/1today's goal
–correct

Up next · 7 min

Timers and Your Own Services

Next lesson
Sources for this lesson
  1. 1
    journalctl(1) manual page. man7.org (Linux man-pages). verifiedWith no arguments shows all logs; -b [ID][±offset] a given boot, --list-boots; -u unit; -p priority, syslog levels emerg (0) to debug (7), a single level shows that and more important; -S/--since and -U/--until with dates, yesterday/today/now, or relative times; -f follow; -k kernel messages; -e jump to end; -n lines; -r reverse; -x catalog explanations; --disk-usage; --vacuum-size/time/files. Members of systemd-journal, adm, and wheel can read all journal files. Examples: journalctl -k -b -1; journalctl -f -u apache.
  2. 2
    systemd/Journal. ArchWiki. verifiedsystemd's logging system; journalctl filtering by boot, unit, priority, and time; journal size limits.
  3. 3
    journald.conf(5) manual page. man7.org (Linux man-pages). verifiedStorage= volatile, persistent, auto, none; persistent stores under /var/log/journal and is the default; SystemMaxUse= defaults to 10% of the file system, SystemKeepFree= to 15%, each capped at 4G.