Journalctl
Journalctl is used to query and display logs from systemd-journald.
Common Usage
View Logs for a Service
Shows logs for a specific service.
sudo journalctl -u <service_name>
Example: sudo journalctl -u caddy
Follow Logs (Live Tail)
Shows the most recent logs and continues to print new log lines as they are appended (like tail -f).
sudo journalctl -fu <service_name>
Example: journalctl -fu caddy
View Kernel Logs
Shows messages from the kernel buffer.
sudo journalctl -k
View Logs Since Boot
Shows logs from the current boot session.
sudo journalctl -b
View Logs by Priority
Shows logs with a specific priority or higher (e.g., "err" for errors).
sudo journalctl -p err
Limit Output Size
Shows the last N lines.
sudo journalctl -n 50