Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Read the logs with journalctl

By updated

Improve this page

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 --since and --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 are enough to get started, 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

Terminal window
journalctl

The output is shown in a pager (like less). Use:

  • Down arrow or Space to move forward
  • q to quit
  • /pattern to 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:

Terminal window
journalctl -n 20

The logs of the current boot

Terminal window
journalctl -b

This shows only the messages since the last boot. To see the previous boot:

Terminal window
journalctl -b -1

This 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, for example SSH on a RHEL server, where the unit is called sshd:

Terminal window
journalctl -u sshd
Output (excerpt)
Apr 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.5
Apr 06 09:15:23 server sshd[1456]: pam_unix(sshd:session): session opened for user bob

The 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:

Terminal window
journalctl -u nginx -b -n 30

This 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:

Terminal window
journalctl -f

To follow a specific service:

Terminal window
journalctl -u nginx -f

To make the most of it, 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 does not give 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:

LevelNameDescription
0emergSystem unusable
1alertImmediate action required
2critCritical error
3errError
4warningWarning
5noticeNormal but significant event
6infoInformation
7debugDebug message

To show only errors and worse (levels 0 to 3):

Terminal window
journalctl -p err

For warnings and worse:

Terminal window
journalctl -p warning

Filter 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 two 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 a very good first diagnostic command: it keeps only the errors of the last hour.

To search the logs of a precise period:

Terminal window
journalctl --since "2026-04-06 08:00" --until "2026-04-06 12:00"

Accepted formats:

FormatExample
Date and time"2026-04-06 08:00"
Date only"2026-04-06" (= midnight)
Relative"1 hour ago"
Relative"yesterday", "today"

Practical examples:

Terminal window
# Errors over the last hour
journalctl -p err --since "1 hour ago"
# Yesterday's Nginx logs
journalctl -u nginx --since yesterday --until today

See the disk space used by the logs

Terminal window
journalctl --disk-usage
Output
Archived and active journals take up 128.0M in the file system.

To free space by deleting old logs:

Terminal window
# Keep only the last 7 days
sudo journalctl --vacuum-time=7d
# Or cap at 500 MB
sudo journalctl --vacuum-size=500M

These two commands also erase the traces of a recent incident. After a problem, first read and copy what helps you understand it, then purge.

Command summary

These ten 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. To go further (rotation, journal management best practices), the Master the Linux system logs with journalctl guide extends this page.

CommandRole
journalctlAll the journals
journalctl -n 20The last 20 lines
journalctl -bLogs of the current boot
journalctl -u serviceLogs of one service
journalctl -fLive follow
journalctl -u service -fLive follow of one service
journalctl -p errErrors and worse
journalctl --since "1 hour ago"Logs of the last hour
journalctl --disk-usageDisk space used
sudo journalctl --vacuum-time=7dDelete 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.

SymptomLikely causeSolution
No journal files were foundJournald is not running, or the user has no access to the system journalsRun sudo journalctl, or add the user to the systemd-journal group (or adm); check that systemd-journald is running
The logs disappear after a rebootNon-persistent storage: with Storage=auto, journald only writes to disk if the /var/log/journal directory existsCreate the directory: sudo mkdir -p /var/log/journal, sudo systemd-tmpfiles --create --prefix /var/log/journal to set permissions and owner, then sudo systemctl restart systemd-journald (or sudo journalctl --flush)
journalctl shows thousands of linesNo filter appliedUse -u, -b, -p or -n to narrow it down
No logs for a serviceThe service does not write to the journalCheck that the service uses stdout/stderr (or syslog)
The disk is full of logsDefault cap too wide for this disk: up to 10% of the file system, within a 4 GB limitSet SystemMaxUse=500M in /etc/systemd/journald.conf

Key points

  • journalctl is the entry point to read the system journals.
  • -u service filters by service: it is the most useful filter day to day.
  • -f follows the logs in real time, ideal for live troubleshooting.
  • -p err shows only errors and more severe levels.
  • --since and --until limit the search to a time range.
  • -b -1 rereads the previous boot, provided the journal is kept on disk (the /var/log/journal directory).

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

6 questions
6 min
70% to pass

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