1.6 KiB
1.6 KiB
journalctl Troubleshooting Guide
This guide provides a structured approach to troubleshooting common issues in Linux using the journalctl command.
General Troubleshooting
- Review Recent Logs
- View recent log entries:
journalctl -e - Show logs since the last boot:
journalctl -b
- View recent log entries:
Service-Specific Issues
- Identify Service Issues
- Display logs for a specific service:
journalctl -u service-name.service- Replace
service-namewith the actual service name, e.g.,journalctl -u sshd
- Replace
- Display logs for a specific service:
System Crashes or Boots
- Investigate Boot Issues
- Display logs from the current boot:
journalctl -b - Show logs from the previous boot:
journalctl -b -1 - List boot sessions to identify specific instances:
journalctl --list-boots
- Display logs from the current boot:
Error Messages
- Filter by Error Priority
- Show only error messages:
journalctl -p err - For more severe issues, consider using higher priority levels like
crit,alert, oremerg
- Show only error messages:
Additional Tips
- Follow Live Logs: Monitor logs in real-time:
journalctl -f - Time-Based Filtering: Investigate issues within a specific timeframe:
- Since a specific time:
journalctl --since "YYYY-MM-DD HH:MM:SS" - Between two timestamps:
journalctl --since "start-time" --until "end-time"
- Since a specific time:
- Output Formatting: Adjust output format for better readability or specific needs:
- JSON format:
journalctl -o json-pretty - Verbose format:
journalctl -o verbose
- JSON format:
- Export Logs: Save logs for further analysis or reporting:
journalctl > logs.txtorjournalctl -u service-name > service_logs.txt