journalctl is the command that displays all the journals of your Linux
system. When a service crashes or something behaves oddly, these logs hold
the answer. This guide teaches you the essential filters to target the useful
information quickly.
What you will learn
- Read the system journals with
journalctl - Filter by service with
-u - Follow the logs in real time with
-f - Filter by priority (errors, warnings)
- Search a date range with
--sinceand--until
What journald is
journald is the systemd component that captures and stores all the system
logs:
- kernel messages,
- service messages (SSH, Nginx, cron…),
- authentication messages,
- system errors.
All these messages are stored in a binary format. The journalctl
command reads and filters them.
This binary storage surprises people who come from the text files of
/var/log/, and it has a useful counterpart: journald's logs are
structured. Each entry carries its metadata, date, PID, emitting
service, priority, which makes filtering exact. A grep on free text
cannot tell one service from another; journalctl -u can.
Read the journals
Three ways of reading the journals cover almost every need, and they differ by what they leave out. The first leaves out nothing and is for exploring; the second keeps only the latest entries, when you know the event just happened; the third keeps only the current boot, which removes at once all the history before the last reboot.
All the logs
journalctlThe output is shown in a pager (like less). Use:
- Down arrow / Space to move forward
qto quit/patternto search for a word
The last lines
This is the form to prefer as soon as you know when the event occurred, because it skips the pager and gives you the prompt back immediately. Pick the number according to the service's verbosity: about twenty lines is enough for a start-up, you need more for a service that writes on every request.
To show only the last 20 entries:
journalctl -n 20The logs of the current boot
journalctl -bThis shows only the messages since the last boot. To see the previous boot:
journalctl -b -1This command only works if the journal is kept on disk between two boots. Otherwise, journalctl answers that it has no data for that boot: the Troubleshooting section shows how to make the journal persistent.
Filter by service with -u
This is the filter used most day to day. To see only the logs of one service:
journalctl -u sshdApr 06 08:00:01 server sshd[850]: Server listening on 0.0.0.0 port 22.Apr 06 09:15:23 server sshd[1456]: Accepted publickey for bob from 192.168.1.5Apr 06 09:15:23 server sshd[1456]: pam_unix(sshd:session): session opened for user bobThe unit name depends on the distribution: the SSH server is called
sshd on RHEL, but ssh on Debian and Ubuntu, where the command
becomes journalctl -u ssh. When in doubt,
systemctl list-units --type=service shows the exact name.
To combine it with the last lines of the current boot:
journalctl -u nginx -b -n 30This command shows the last 30 Nginx messages since the last boot.
Follow the logs in real time with -f
The equivalent of tail -f for systemd journals:
journalctl -fTo follow a specific service:
journalctl -u nginx -fThe most effective way to use this is to open a second terminal with
journalctl -u <service> -f, then start or test the service from the
first one. The errors show up as they happen, in order, which reading
after the fact never gives you as clearly.
Press Ctrl+C to stop following.
Filter by priority with -p
Each journal message has a priority level. From the most critical to the least important:
| Level | Name | Description |
|---|---|---|
| 0 | emerg | System unusable |
| 1 | alert | Immediate action required |
| 2 | crit | Critical error |
| 3 | err | Error |
| 4 | warning | Warning |
| 5 | notice | Normal but significant event |
| 6 | info | Information |
| 7 | debug | Debug message |
To show only errors and worse (levels 0 to 3):
journalctl -p errFor warnings and worse:
journalctl -p warningFilter by date with --since and --until
This is the filter you use after the fact, when someone reports an incident
that happened "around 9 this morning". The 2 options work alone or
together: --since sets the start, --until the end. They combine
with all the other filters, and journalctl -p err --since "1 hour ago" is
probably the most rewarding diagnostic command in this guide.
To search the logs of a precise period:
journalctl --since "2026-04-06 08:00" --until "2026-04-06 12:00"Accepted formats:
| Format | Example |
|---|---|
| Date and time | "2026-04-06 08:00" |
| Date only | "2026-04-06" (= midnight) |
| Relative | "1 hour ago" |
| Relative | "yesterday", "today" |
Practical examples:
# Errors over the last hourjournalctl -p err --since "1 hour ago"
# Yesterday's SSH logsjournalctl -u sshd --since yesterday --until todaySee the disk space used by the logs
journalctl --disk-usageArchived and active journals take up 128.0M in the file system.To free space by deleting old logs:
# Keep only the last 7 dayssudo journalctl --vacuum-time=7d
# Or cap at 500 MBsudo journalctl --vacuum-size=500MCommand summary
These 10 forms can be combined with each other, and that is what makes the
tool powerful: -u designates the service, -b the boot, -p the severity,
-n the volume, --since the period. So there are not ten commands to
memorise, but five filters to assemble according to the question asked.
| Command | Role |
|---|---|
journalctl | All the journals |
journalctl -n 20 | The last 20 lines |
journalctl -b | Logs of the current boot |
journalctl -u service | Logs of one service |
journalctl -f | Live follow |
journalctl -u service -f | Live follow of one service |
journalctl -p err | Errors and worse |
journalctl --since "1 hour ago" | Logs of the last hour |
journalctl --disk-usage | Disk space used |
sudo journalctl --vacuum-time=7d | Delete logs older than 7 days |
Troubleshooting
The difficulties met with journalctl rarely come from the command itself:
they come from the journald configuration, in particular the
persistence of the journals between two boots and the size they are
allowed to take. Both are set in /etc/systemd/journald.conf.
| Symptom | Likely cause | Solution |
|---|---|---|
No journal files were found | Journald is not running or permissions are insufficient | Run sudo journalctl, or add the user to the systemd-journal group (or adm); check that systemd-journald is running |
| The logs disappear after a reboot | Non-persistent storage (the default on some distributions) | Create the directory: sudo mkdir -p /var/log/journal then sudo systemctl restart systemd-journald |
journalctl shows thousands of lines | No filter applied | Use -u, -b, -p or -n to narrow it down |
| No logs for a service | The service does not write to the journal | Check that the service uses stdout/stderr (or syslog) |
| The disk is full of logs | Default cap too wide for this disk: up to 10% of the file system, within a 4 GB limit | Set SystemMaxUse=500M in /etc/systemd/journald.conf |
Key points
journalctlis the single entry point to read all the system journals.-u servicefilters by service: it is the most useful filter day to day.-ffollows the logs in real time, ideal for live troubleshooting.-p errshows only errors and critical messages.--sinceand--untillimit the search to a time range.
Knowledge check
Check that the essentials of this guide stuck. The questions cover only what has just been explained here.
Knowledge check
Check what you have learned with this interactive quiz
How it works
- The timer starts when you click Start
- Multiple choice, true/false and short answer questions
- You can move between questions
- Detailed results are shown at the end
Starts the quiz and the timer
Review
(0/0)Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: First troubleshooting steps on Linux
A new full quiz with random questions
Work again only on the questions you missed