Systemd usage

From wikinotes

Instructions on viewing, configuring, monitoring your system's services/timers/targets.

Documentation

man systemctl https://man.archlinux.org/man/core/systemd/systemctl.1.en

Service Management

Manage Service

systemctl {enable,start,stop,restart} myservice

Override Service Options

# creates /etc/systemd/system/myservice.service.d/override.conf
# where you can override service settings
systemctl edit myservice.service

Info about services/status

systemctl {is-active,is-enabled} myservice

systemctl show \
  [-p property,...]  `# list specific properties` \
  [foo.service]      `# filter to unitfile` \

System Management

systemctl --system daemon-reload          # reload unitfiles
systemctl [--user] list-units -t target   # list all targets

# list filepaths for each service
for service in $(systemctl list-units -t service,timer | head -n -6 | sed -n '2,$p'  | sed -E 's/^[^a-zA-Z0-9]+//' | awk -F' ' '{ print $1 }'); do
  systemctl show -P Id,FragmentPath "$service" | sed 'N;s/\n/ /'
done | column -t

systemctl {list-units,list-timers,list-sockets}

Logs

See systemd journald