systemd

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

  1. /etc
  2. /run
  3. /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