systemd command snippets

Copy-paste-ready systemctl and journalctl commands for common service management tasks.

systemd command snippets

Copy-paste-ready systemctl and journalctl commands for common service management tasks.

List All Running systemd Services

systemctl lists all active service units with their state:

systemctl list-units --type=service --state=running

List All Failed systemd Services

systemctl shows services that failed to start:

systemctl list-units --type=service --state=failed

Show the Full Unit File for a systemd Service

systemctl displays the merged unit file including all drop-in overrides:

systemctl cat nginx.service

List All systemd Timers with Next Run Time

systemctl shows all timers with their next and last trigger times:

systemctl list-timers --all

View systemd Journal for the Current Boot Only

journalctl filters entries to the current boot session:

journalctl -b

View systemd Journal Entries by Priority Level

journalctl shows only error-level and higher messages:

journalctl -p err -b

Show Disk Usage of the systemd Journal

journalctl reports the total size of stored journal files:

journalctl --disk-usage

Rotate and Vacuum the systemd Journal

journalctl removes old entries to free disk space. Keep only the last 500 MB:

sudo journalctl --vacuum-size=500M

Analyze systemd Boot Time

systemd-analyze shows the total boot time and the slowest services:

systemd-analyze
systemd-analyze blame

Reset a Failed systemd Service

systemctl clears the failed state so the service can be restarted:

sudo systemctl reset-failed myapp.service