systemd & systemctl
Start, stop, enable and inspect services with systemd's systemctl command.
What systemd does
systemd is the init system on almost every current distro (Ubuntu, Debian, RHEL/Fedora, Arch, openSUSE). It starts services at boot, restarts them if they crash, and tracks their state as "units" β most commonly .service files. Alpine is the exception: it uses OpenRC, with rc-service/rc-update instead of systemctl.
Start, stop and restart a service
These act immediately on the running service without changing whether it starts at boot.
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx # re-read config without dropping connections, if supportedEnable a service at boot
enable only changes whether the service starts on the next boot; it does not start it now. --now does both in one step.
sudo systemctl enable nginx
sudo systemctl enable --now nginx # enable and start immediately
sudo systemctl disable nginxCheck status and logs
status gives a quick health snapshot including the last few log lines; journalctl -u gives the full log for that unit.
systemctl status nginx
journalctl -u nginx -n 50 # last 50 lines
journalctl -u nginx -f # follow liveList units
Useful for seeing everything running, or everything that failed.
systemctl list-units --type=service --state=running
systemctl --failed