When your Linux system crashes, understanding the cause is crucial for troubleshooting. The journalctl
command helps you analyze system logs, including crash reports. This guide explains how to use journalctl
to check why your system crashed in the last boot.
Step 1: View Logs from the Previous Boot
To check logs from the last boot, use the following command:
journalctl -b -1
Here, -b -1
means "show logs from the previous boot." If you want logs from two boots ago, use -b -2
, and so on.
Step 2: Filter Logs for Errors
To see only errors from the last boot, run:
journalctl -b -1 -p 3
The -p 3
option filters logs by priority, showing only errors (priority 3) and higher (critical and alert messages).
Step 3: Check Kernel Logs
Kernel messages often contain information about crashes. To see only kernel logs from the last boot, use:
journalctl -k -b -1
Step 4: Identify the Crash Reason with Systemd Logs
To find if systemd recorded any failures, run:
journalctl -b -1 -u systemd-coredump
The systemd-coredump
service logs crash dumps of applications, which can help pinpoint the issue.
Step 5: Analyze Segmentation Faults and Core Dumps
If a program caused a segmentation fault, you can check:
journalctl -b -1 | grep 'segfault'
For core dump analysis, run:
coredumpctl list
To inspect a specific core dump:
coredumpctl info <PID>
Replace <PID>
with the process ID from the coredumpctl list
output.
Step 6: Check Power or Hardware Issues
If you suspect power failures or hardware issues, look for messages related to abrupt shutdowns:
journalctl -b -1 | grep -i 'power off'
To check for disk errors:
journalctl -b -1 | grep -i 'I/O error'
By using journalctl
, you can investigate the cause of a system crash and take appropriate action. If logs indicate software issues, updating or reinstalling the package may help. If hardware failures are detected, consider checking system components.
These easy steps will help you effectively diagnose and resolve crashes in Linux. For more details on journal logs and troubleshooting in Linux, visit ArchWiki:
Top comments (0)