journalctl
Reading system logs with journalctl and the kernel ring buffer (dmesg).
Common invocations
All logs for current boot:
journalctl -bLogs from previous boot:
journalctl -b -1List boots with timestamps:
journalctl --list-bootsOnly errors and above:
journalctl -b -p errFollow live (like tail -f):
journalctl -fRecent logs (last 10 minutes):
journalctl --since "10 min ago"Time range:
journalctl --since "2025-01-01" --until "2025-01-02"Jump to end:
journalctl -eLast N lines:
journalctl -n 50Newest first:
journalctl -r
Filter by unit
Specific service:
journalctl -u NetworkManagerFollow one service:
journalctl -fu nginxUser service:
journalctl --user -u wireplumber -n 50 --no-pager
Filter by priority
-p shows the specified level and above (more severe).
| Level | Name |
|---|---|
| 0 | emerg |
| 1 | alert |
| 2 | crit |
| 3 | err |
| 4 | warning |
| 5 | notice |
| 6 | info |
| 7 | debug |
Errors and above:
journalctl -p errPriority range:
journalctl -p err..crit
Advanced filters
Kernel messages only:
journalctl -kBy PID:
journalctl _PID=1234By UID:
journalctl _UID=1000By binary path:
journalctl /usr/bin/nginxBy transport (kernel/audit):
journalctl _TRANSPORT=kernelCombine filters (AND):
journalctl -b -p err _TRANSPORT=kernel
Output formats
Pretty JSON:
journalctl -o json-prettyISO timestamps:
journalctl -o short-isoMessage only:
journalctl -o catAll fields, verbose:
journalctl -o verbose
Filter by keyword
Pipe to grep:
journalctl -b | grep -i hdmijournalctl -b | grep amdgpuOpen in nvim for searching:
journalctl --since "15 min ago" | nvim
Useful one-liners
Resume from suspend:
journalctl -b -1 | grep -i resumeLid events:
journalctl -f | grep -i lidSuspend/hibernate image:
journalctl -b | grep -i "PM: Image"Kernel messages (dmesg-style, with color/highlight):
sudo journalctl -kg
Journal disk management
Total disk usage:
journalctl --disk-usageRotate now:
sudo journalctl --rotateVacuum by time:
sudo journalctl --vacuum-time=7dVacuum by size:
sudo journalctl --vacuum-size=500MVacuum by file count:
sudo journalctl --vacuum-files=5Verify integrity:
journalctl --verify
journald configuration
File: /etc/systemd/journald.conf
[Journal]
Storage=persistent
Compress=yes
SystemMaxUse=500M
SystemMaxFileSize=50M
MaxRetentionSec=1month
MaxFileSec=1week
Apply with sudo systemctl restart systemd-journald.
dmesg (kernel ring buffer)
Show kernel messages:
dmesgHuman-readable timestamps:
dmesg -TColor output:
dmesg --color=alwaysFollow live:
dmesg -wFilter by facility:
dmesg -f kernFilter by level:
dmesg -l err,warnCommon searches:
dmesg | grep -i usb dmesg | grep -i "nvidia\|amd\|gpu" dmesg | grep -i oom dmesg | grep -i "error\|fail"Clear ring buffer:
sudo dmesg -C
Boot analysis
Total boot time breakdown:
systemd-analyzePer-unit boot times:
systemd-analyze blameCritical chain:
systemd-analyze critical-chainPer-unit critical chain:
systemd-analyze critical-chain nginx.serviceSVG visualization:
systemd-analyze plot > boot-chart.svg