Systemd services commands
mouse 1887 · person cloud · link
Last update
2019-12-31
2019
12-31
« — »
1
2
3
4
5
6
7
8
9
10
11
12
13
systemctl # list running services

# basic service management
systemctl start      foo.service
systemctl stop       foo.service
systemctl restart    foo.service
systemctl status     foo.service

# manage start on boot
systemctl enable     foo.service
systemctl disable    foo.service
systemctl is-enabled foo.service
systemctl list-unit-files # see all enabled/disable units

Debug and logs:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
journalctl            # inspect all logs
journalctl -b-1 -e    # inspect last boot logs

systemd-analyze blame # time consumed

cat /var/log/boot.log

# boot graphs:
apt-get install graphviz
systemd-analyze plot > boot-chart.svg
systemd-analyze           dot | dot -Tsvg > boot-full.svg
systemd-analyze --order   dot | dot -Tsvg > boot-order.svg
systemd-analyze --require dot | dot -Tsvg > boot-require.svg

systemctl list-dependencies
systemd-analyze critical-chain

Add a new unit (see docs):

1
2
3
4
ln -f /opt/systemd-units/name.service /lib/systemd/system/
systemctl enable name.service

systemctl daemon-reload # reload all modified units

Note: Do NOT use symlinks otherwise systemd won't enable them.


Source: Dynacont