Code-Memo

systemd and systemctl

What is systemd?

systemd is the init system on many Linux distros. It starts services (units), manages dependencies, logs to the journal, and handles targets (boot states).

systemctl basics

List units:

systemctl list-units
systemctl list-units --type=service
systemctl list-unit-files --type=service

Service lifecycle:

sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
systemctl status nginx

Enable at boot:

sudo systemctl enable nginx
sudo systemctl disable nginx

Logs (journal)

journalctl -u nginx
journalctl -u nginx -f

Unit file locations

Reload after unit changes:

sudo systemctl daemon-reload
sudo systemctl restart <unit>