systemd Units & Services
systemd Units
systemd manages the system via units. Unit types include .service, .socket, .target, .mount, .timer.
| Command | Action |
|---|---|
systemctl start nginx | Start now |
systemctl stop nginx | Stop now |
systemctl restart nginx | Restart |
systemctl reload nginx | Reload config (no downtime) |
systemctl enable nginx | Start at boot |
systemctl disable nginx | Don't start at boot |
systemctl enable --now nginx | Enable and start |
systemctl status nginx | Current state |
systemctl is-active nginx | active/inactive |
systemctl list-units --type=service | All services |
Unit files live in /etc/systemd/system/ (admin) and /lib/systemd/system/ (packages). After editing, run systemctl daemon-reload.
$ systemctl enable --now sshd
Created symlink /etc/systemd/system/multi-user.target.wants/sshd.service.
Exam trap:start≠enable.startruns it now;enablemakes it start on boot. You usually want both.