Skip to content

Instantly share code, notes, and snippets.

@henri
Last active May 2, 2025 20:00
Show Gist options
  • Save henri/cee8957e0c83d8c9871ada9a23a12ad3 to your computer and use it in GitHub Desktop.
Save henri/cee8957e0c83d8c9871ada9a23a12ad3 to your computer and use it in GitHub Desktop.
systemd cheat sheets
# reload the systemd deamon config files (useful for testing once you have made a change)
systemctl daemon-reload
# list all unit configuration files found in the search paths.
systemctl list-unit-files
# list units with descriptions which are currently loaded into memory
systemctl list-units
# lists units with additional information
systemctl list-units --all
# list failed services
systemctl list-units --type=service --state=failed
# list failed - generic
systemctl --failed
# list running services
systemctl list-units --type=service --state=running
# list enabled services
systemctl list-unit-files --type=service --state=enabled
# display enabled /disabled status of single unit
systemctl is-enabled <servicename>
output explanation - enabled : service is enabled and set to start at boot
- disabled : service is disabled and won't start at boot
- static : service is enabled but will not start at boot
# display active / inactive status of single unit
systemctl is-enabled <servicename>
output explanation - active
- inactive
# find the paths of installed unit files using the locate command (may require install of plocate)
locate '*.service'
# find the paths of installed unit files within /etc/ and /var/ using the find command (may be slower)
find /etc /var -type f -name '*.service'
# list how long boot takes
systemd-analyze
# show which parts take how long to boot
systemd-analyze blame
# show the path the actual overide file :
systemctl show --property=DropInPaths <unit-name>
# show all set values for a unit :
systemctl show <unit-name>
# edit the overide file for a unit
sudo systemctl edit <unit-name>
# reload the systemd datrabase after editing overide files
systemctl daemon-reload
[Unit]
# require another unit
Requires=<unit.target>
# specify the order
After=<unit.target>
Before=<unit.target>
# ---------------------------------------------
[Service]
# Restart on failure with a delay
Restart=on-failure
RestartSec=10 # Set the delay in seconds
[Service]
# Startup delay
ExecStartPre=/bin/sleep 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment