systemd is the init system used by most modern Linux distributions. It's the first process that starts when Linux boots and the parent of everything else. Understanding it makes managing servers significantly easier.
What it does
systemd starts and manages services, handles logging via journald, manages scheduled tasks via timers, and controls the boot process. When you run systemctl start nginx you're talking to systemd. When you run journalctl -u nginx you're reading logs that systemd collected. It's the backbone of how services are managed on modern Linux.
The commands you actually use
# Start/stop/restart a service systemctl start nginx systemctl stop nginx systemctl restart nginx # Enable/disable on boot systemctl enable nginx systemctl disable nginx # Check status systemctl status nginx # View logs journalctl -u nginx journalctl -u nginx -f # follow live journalctl -u nginx --since "1 hour ago"
systemctl enable and systemctl start are different things. Enable means start on boot. Start means start now. You usually want both — systemctl enable --now nginx does both in one command.
Writing a service file
You can run anything as a systemd service by writing a unit file in /etc/systemd/system/:
[Unit] Description=My App After=network.target [Service] Type=simple User=theo WorkingDirectory=/opt/myapp ExecStart=/usr/bin/node server.js Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target
Save that as /etc/systemd/system/myapp.service, run systemctl daemon-reload, then systemctl enable --now myapp. Your app now starts on boot, restarts on failure, and logs to journald automatically.
Why I use it alongside Docker
For most things I use Docker Compose with restart: unless-stopped. But for services that need tighter system integration, or that need to start before Docker does, systemd services are the right tool. Cloudflared (Cloudflare Tunnel daemon) runs as a systemd service on my servers. Wings (Pterodactyl) runs as a systemd service. Both need to be up reliably on every boot.