Skip to content

Instantly share code, notes, and snippets.

@henri
Last active May 1, 2026 04:01
Show Gist options
  • Select an option

  • Save henri/cee8957e0c83d8c9871ada9a23a12ad3 to your computer and use it in GitHub Desktop.

Select an option

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 specific unit files
systemctl list-unit-files | grep -iE 'unit-name-1|unit-name-2|unit-name-3'
# 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 disabled services
systemctl list-units --type=service --state=disabled
# 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
# run directory setting when you login for a user - below is the default
/etc/systemd/logind.conf -> [Login] -> RuntimeDirectorySize=10%
# 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
# start a process with a memory limit
systemd-run --user --scope -p MemoryMax=8g -p MemorySwapMax=8G <executable>
# check on scope status
systemctl --user status run-*.scope
# reset a failed scope
systemctl --user reset-failed run-*.scope
[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
# show information focused on linger / state for a particular users login units / timers etc...
loginctl show-user <user> | grep -E "Linger|Sessions|State"
# show information about a user and if Linger is enabled
loginctl show-user $USER | grep Linger
ls /var/lib/systemd/linger/
# show user session status
loginctl list-users
# disable linger for your account
loginctl disable-linger $USER
# enable linger for your account
loginctl enable-linger $USER
# start a job in user space which runs every 30 seconds and prints the date into a file (this unit is called jobe)
# use systemctl to stop timers like this or other kinds of units *see below
# use systemctl to show information about timers and other kinds of units * see below
systemd-run --user --on-active=1 --on-unit-active=30 --unit=job bash -c 'date >> /tmp/date.log'
# reset failed unit / and timer called 'job' by name (user - not system)
systemctl --user reset-failed job.service
systemctl --user reset-failed job.service
# stop unit called 'job (user - not system)
systemctl --user stop job.timer
systemctl --user stop job.service
# show details about a timer called 'job' started with systemctl-run
systemctl --user show job.timer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment