The journalctl command
The journalctl command reads the systemd log…
The journalctl command reads the systemd log: journalctl -u nginx shows one service’s messages, and journalctl -f follows new ones as they arrive.
Taught in Advanced, lesson 42; more in Ninja
A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.
Usage
journalctl [-u SERVICE] [-n N] [-f] [-p PRIORITY] [--since TIME]
Read the system log. Shows log messages from services and the system, oldest first. -u nginx narrows it to one service, -n 20 shows the last 20 lines, -f keeps showing new lines as they arrive (Ctrl+C stops it), and -p err shows only errors. When a service won’t start, journalctl -u SERVICE -n 20 nearly always says why. You need to be in the adm group (or use sudo) to see the system’s messages. Everything here is simulated in the page: no real accounts, passwords or software are involved.
In the practice terminal:The log is the practice machines’ own pretend journal, inside the page: services starting and stopping, cron jobs, and what you write with logger.
How to use journalctl
The latest messages: journalctl -n
With no options, journalctl shows the whole log, oldest first, in a pager. -n 20 shows the last 20 lines and -r puts the newest first.
journalctl -n 5Jan 09 06:12:04 sandbox systemd[1]: Starting cron.service - Regular background program processing daemon... Jan 09 06:12:04 sandbox systemd[1]: Started cron.service - Regular background program processing daemon.
One service: journalctl -u
ssh webThe authenticity of host 'web (10.0.0.10)' can't be established. ED25519 key fingerprint is SHA256:aaVFThjlH4/WIvuW5JbeDsUSex1ZSOHtUS3pZXDPB10. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'web' (ED25519) to the list of known hosts. learner@web's password: Welcome to Ubuntu 24.04 LTS (practice web server web) This is a pretend machine inside your browser. Type exit to go back to sandbox. Last login: Mon Jan 12 06:39:27 2026 from 10.0.0.5
journalctl -u nginx -n 5Jan 09 06:12:05 web systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy server... Jan 09 06:12:05 web systemd[1]: Started nginx.service - A high performance web server and a reverse proxy server.
Only errors: journalctl -p err
Priorities run from emerg down to debug; -p err shows errors and anything worse. logger writes a line to the log, as scripts do.
logger -p user.err "backup failed: disk full"journalctl -p errJan 12 09:01:00 sandbox learner: backup failed: disk full
Since a time: journalctl --since
logger "backup done"journalctl --since "10 minutes ago"Jan 12 09:01:00 sandbox learner: backup done
Follow the log: journalctl -f
New lines appear as they are written, like tail -f. Press Ctrl+C to stop.
journalctl -fJan 09 06:12:04 sandbox systemd[1]: Starting cron.service - Regular background program processing daemon... Jan 09 06:12:04 sandbox systemd[1]: Started cron.service - Regular background program processing daemon. ^C
Options
| -u SERVICE | only this service |
|---|---|
| -n N | the last N lines |
| -f | follow: keep printing new lines |
| -e | jump to the end |
| -p PRIORITY | only this important or worse: err, warning, info |
| -r | newest first |
| --since TIME | from then on: today, "-10min", "2 hours ago" |
More examples
journalctl -u cron -n 3Jan 09 06:12:04 sandbox systemd[1]: Starting cron.service - Regular background program processing daemon... Jan 09 06:12:04 sandbox systemd[1]: Started cron.service - Regular background program processing daemon.
Questions about journalctl
What is the difference between journalctl and /var/log/syslog?
journalctl reads systemd’s journal, which keeps every service’s messages with their priority and unit. Ubuntu also writes a plain-text copy to /var/log/syslog, which you can read with less or grep.
How do I see the log since the last boot?
journalctl -b shows the messages since the machine started, and journalctl -b -1 those of the boot before.
Why does journalctl say "No entries"?
Nothing matched what you asked for: the service name, the time or the priority. Check the unit’s name with systemctl list-units.
Learn it step by step
Related commands
Every everyday command on one page, to print or keep open: the Linux commands cheat sheet.