systemd Commands
Init system, systemctl and journalctl.All systemd pages
- Create a systemd service for a script or app (.service file)Create /etc/systemd/system/myapp.service with ExecStart, run daemon-reload and enable --now. A minimal unit, Type= choices, restarts, and common mistakes.
- journalctl -u nginx -f: follow the logs of one systemd servicejournalctl -u NAME -f shows one service's log and follows new lines like tail -f. Add -n, --since, -b, -p err and --no-pager to filter by time and priority.
- systemctl --failed: list failed services and see whysystemctl --failed lists failed systemd units; systemctl status and journalctl -u show why they failed. Common Result values, reset-failed, and restarting.
- systemctl enable --now: start a service and enable it at bootsudo systemctl enable --now NAME starts a service now and at every boot; disable --now undoes it. is-enabled states, mask, and the errors enable can print.