← Back to Home

Linux journalctl: Querying System Logs

2026.07.19 · Linux · 3 min read

Goal

Use systemd logs to find the root cause of system anomalies — reboots, crashes, overheating, OOM, Kernel Panic.

When You'd Use This

Key Commands

Basics

journalctl -n 50                    # last 50 lines
journalctl -f                       # follow in real time
journalctl --since "1 hour ago"     # the last hour
journalctl -u ssh.service           # only one service

Boot Management

last reboot                        # reboot history
journalctl --list-boots             # list of Boot IDs
journalctl -b 0                     # current boot
journalctl -b -1                    # previous boot
journalctl -b -2                    # two boots ago
journalctl -b -2 -e                 # end of previous boot (check shutdown)

A clean shutdown ends with:

System is going down for poweroff
Reached target Power-Off

Troubleshooting

journalctl -b -1 | grep -i "temperature\|thermal"   # overheating check
journalctl -b -1 | grep -i "oom\|out of memory"      # OOM check
journalctl -b -1 | grep -i "panic"                   # Kernel Panic check

Log Maintenance

sudo journalctl --vacuum-time=30d      # keep 30 days
sudo journalctl --vacuum-size=500M     # cap size at 500MB

A Real Case

7/18 power outage: my desktop I610M4 was offline for about a day, from 7/18 to the afternoon of 7/19.

last reboot confirmed the last boot was 7/19 22:56 → journalctl -b -2 -e showed no clean shutdown message for the previous boot → no overheating/OOM/Panic entries → Conclusion: an external power outage.


Notes

This note is also kept in my Obsidian knowledge base. Related topics: dmesg, systemd, OOM Killer, Kernel Panic.