Beginner · Processes, services and logs · topic 17 of 57 · 30 min
Logs: journalctl, rsyslog and a persistent journal
Explanation
Two log systems working together
On RHEL 9, systemd-journald receives log messages from the kernel, from services' output, and from programs using syslog. It stores them in a structured, indexed journal. rsyslog then reads from the journal and writes classic text files in /var/log. Both are useful: journalctl has powerful filters, and text files are easy to grep and to ship to a central log server.
| File | What goes there |
|---|---|
| /var/log/messages | Most system messages |
| /var/log/secure | Logins, sudo, SSH (security and authentication) |
| /var/log/cron | Scheduled jobs |
| /var/log/maillog | Mail server |
| /var/log/boot.log | Boot-time service messages |
| /var/log/audit/audit.log | Audit events, including SELinux denials (written by auditd) |
Reading the journal
$ journalctl -u sshd # one service
$ journalctl -u httpd --since "1 hour ago"
$ journalctl -p err -b # errors and worse, this boot
$ journalctl -f # follow, like tail -f
$ journalctl -n 20 # last 20 lines
$ journalctl --since "2026-10-19 09:00" --until "2026-10-19 09:30"
$ journalctl _PID=1301 # one process
$ journalctl -b -1 # the previous boot (needs a persistent journal)
$ journalctl -o verbose -n 1 # every field of one entryPriorities, from most to least serious: 0 emerg, 1 alert, 2 crit, 3 err, 4 warning, 5 notice, 6 info, 7 debug. -p err shows level 3 AND everything more serious (0 to 3). journalctl only shows everything to root and to members of the wheel or systemd-journal groups; others see only their own messages.
Making the journal persistent
By default the journal setting is Storage=auto: journald writes to /var/log/journal if that directory exists, otherwise only to /run/log/journal, which is in memory and lost at every reboot. Without a persistent journal you cannot read logs from before the last reboot, which is exactly when you need them after a crash. Check with ls /var/log/journal.
# mkdir -p /var/log/journal
# systemctl restart systemd-journald
# journalctl --list-boots
IDX BOOT ID FIRST ENTRY LAST ENTRY
-1 4b1c9e2d3f... Sun 2026-10-18 09:01:02 IST Sun 2026-10-18 23:59:10 IST
0 9a7f6e5d4c... Mon 2026-10-19 09:00:58 IST Mon 2026-10-19 11:05:31 ISTPersistent journals are limited in size (by default up to 10% of the file system, with a cap). journalctl --disk-usage shows the size, and journalctl --vacuum-time=2weeks removes older entries. Classic text files are rotated by logrotate, configured in /etc/logrotate.conf and /etc/logrotate.d/.
Writing your own log lines
$ logger -p user.notice "Backup finished: 12 GB"
$ journalctl -n 1
Oct 19 11:10:02 web01 asha[7720]: Backup finished: 12 GBCommon mistakes
- Looking for yesterday's crash with journalctl -b -1 and getting "Specifying boot ID or boot offset has no effect, no persistent journal was found." Make the journal persistent before you need it.
- Reading only /var/log/messages. Login problems are in /var/log/secure; SELinux denials are in /var/log/audit/audit.log.
- Forgetting that time filters use the server's time zone. Check with timedatectl when comparing with users' reports.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
Logs: journalctl, rsyslog and a persistent journal · 1/7
journald collects logs from the kernel and every service. rsyslog writes classic text files.
Prefer a video by a teacher? Find free videos on “journalctl tutorial persistent journal rhel” on YouTube ↗
In real life: Why did the payments server reboot at 3 am?
A payments company in Pune finds a server rebooted overnight. Because the team had made the journal persistent on all servers, the engineer runs journalctl -b -1 -p warning and sees, at 02:58, kernel messages about memory errors followed by a watchdog reset. The hardware team replaces a memory module the same day. Without the persistent journal, those lines would have been lost.
# journalctl -b -1 -p warning --no-pager | tail -3
Oct 19 02:58:11 pay03 kernel: EDAC MC0: 1 CE memory read error on CPU_SrcID#0_Ha#0_Chan#1_DIMM#0
Oct 19 02:58:40 pay03 kernel: mce: [Hardware Error]: Machine check events logged
Oct 19 02:59:02 pay03 kernel: watchdog: BUG: soft lockup - CPU#3 stuck for 23s!Practice (0/3 done)
Which command shows only the logs of the sshd service?
journalctl -p LEVEL shows messages at that priority and every MORE serious one. Write shown(message_level, filter_level) that returns True if a message is shown. Levels are names: emerg=0, alert=1, crit=2, err=3, warning=4, notice=5, info=6, debug=7. Example: shown("crit", "err") is True; shown("info", "warning") is False.
Make the journal persistent on your lab VM, reboot, and show the logs of the previous boot at priority err or worse.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Tuning profiles with tuned, and time with chronyProcesses, services and logs · same module
- One-time jobs with at, and systemd timersAutomation basics: scheduling, archives and shell scripts
- Persistent storage and containers as systemd servicesBoot, recovery and containers
- Linux security basicsCyber Security: from zero to SOC analyst · Systems and cryptography
- Processes, signals and systemd servicesDevOps: Git, Docker, Kubernetes and CI/CD · Linux for DevOps
- Exam strategy and lab habitsCertifications and career
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
Where are failed SSH logins recorded as text?
Answer: /var/log/secure
Authentication events go to /var/log/secure.
journalctl -p warning shows which levels?
Answer: warning and all more serious levels (0 to 4)
-p shows that priority and higher (lower numbers).
Without /var/log/journal, where does journald keep logs?
Answer: /run/log/journal, lost at reboot
With Storage=auto and no /var/log/journal, logs stay in /run (RAM).
Which command writes a custom message to the system log?
Answer: logger
logger sends a message to the logging system.
What does journalctl -b -1 show?
Answer: The previous boot
-b -1 means one boot before the current one.
What does Persistent=true do in a timer?Related
Answer: Runs a missed job soon after boot if the machine was off at the scheduled time
It catches up on missed runs.
What happens to files written inside a container (not in a volume) after podman rm?Related
Answer: They are deleted with the container
The container layer is removed.
Why use sudo instead of logging in as root?Related
Answer: Each admin action is tied to a named user and logged
Named users plus logging gives accountability and fewer mistakes.
Which command shows the logs of the service orders-api and keeps following new lines?Related
Answer: journalctl -u orders-api -f
journalctl -u selects the unit and -f follows new entries.
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- 1 more topic in “Processes, services and logs” before its exam: Tuning profiles with tuned, and time with chrony.
- Module 3 exam: Processes, services and logs · 14 questions · 25 min, without help. 6 topics of this module still to finish first.
- Then the next module, Software and networking. 57 topics left in the course before the final exam.