systemd
unit
-
Unit types
- automount
- device
- mount
- path
- scope
- service
- slice
- snapshot
- socket
- swap
- target
- timer
instantiated unit
systemd - cheatsheet
List active units
systemctl list-units
/systemctl
/sc-list-units
List active sockets
systemctl list-sockets
/sc-list-sockets
List all running services
systemctl --state running
/sc --state running
Display unit status
systemctl status <unit>
/sc-status <unit>
Display unit properties
systemctl show <unit>
/sc-show <unit>
Display unit config
systemctl cat <unit>
/sc-cat <unit>
Create snippet to override a part of unit file
systemctl edit <unit>
/sc-edit <unit>
Reload changed unit files
systemctl daemon-reload
/sc-daemon-reload
Reload changed configuration file
systemctl reload
Revert unit file changes by deleting overriding snippet file
systemctl revert <unit>
/sc-revert <unit>
Start/Stop a service
-
sudo systemctl start/stop <service-name>.service
e.g.
sudo systemctl stop bluetooth.service
Enable/Disable a service from auto-start
sudo systemctl enable/disable <service-name>.service
Start system in text mode (Fedora)
systemctl set-default multi-user.target
Start system in graphical mode (Fedora)
systemctl set-default graphical.target
Display unit paths
systemd-analyze --user unit-paths
Configuration files priority
/etc
/run
/usr/lib
Display an overview of overridden or modified unit files
systemd-delta --type=extended
journald
journald - cheatsheet
Display unit log
# Single unit
journalctl -u $unit
# Multiple units
journalctl -u $unit1 -u $unit2 ...
Display logs from the current boot
journalctl -b
List past boots
journalctl --list-boots
Display logs since yesterday
journalctl --since yesterday
Display logs of a specific process
journalctl _PID=$pid
Display logs of the current user
journalctl _UID=$(id -u)
Display kernel logs
journalctl -k
Display logs in JSON format
# Compact
journalctl -o json
# Pretty print
journalctl -o json-pretty
resolved
resolved - cheatsheet
DNS domain lookup
resolvectl query <domain>
DNS IP reverse lookup
resolvectl query <IP>
Show DNS configuration
resolvectl status
Show DNS servers
resolvectl dns
WSL
Resources
- systemd.unit — Unit configuration (opens in a new tab)
- DigitalOcean - How To Use Systemctl to Manage Systemd Services and Units | DigitalOcean (opens in a new tab)
- DigitalOcean - How To Use Journalctl to View and Manipulate Systemd Logs (opens in a new tab)
- How To Configure a Linux Service to Start Automatically After a Crash or Reboot – Part 1: Practical Examples | DigitalOcean (opens in a new tab)
- How To Configure a Linux Service to Start Automatically After a Crash or Reboot – Part 2: Reference | DigitalOcean (opens in a new tab)
- linode - systemctl Commands: Restart, Reload, Stop Service and More (opens in a new tab)