Code-Memo

Service units and targets

Unit types

Common unit types:

List unit files:

systemctl list-unit-files
systemctl list-unit-files --type=timer

Targets

Targets are like runlevels (modern).

systemctl get-default
systemctl list-units --type=target

Switch default target:

sudo systemctl set-default multi-user.target
sudo systemctl set-default graphical.target

Overrides (drop-ins)

Create an override:

sudo systemctl edit nginx

This writes a drop-in under: /etc/systemd/system/nginx.service.d/override.conf

Apply changes:

sudo systemctl daemon-reload
sudo systemctl restart nginx

Inspect dependencies

systemctl cat nginx
systemctl show -p FragmentPath nginx
systemctl list-dependencies nginx