← All tools

systemd Unit Generator

A correct service unit from a form — restart policy, sandboxing, and the install commands.

Why this exists

Every long-running service on a modern Linux box is a systemd unit, and hand-written ones repeat the same mistakes: no Restart= so the service dies at 3 a.m. and stays dead, running as root by accident, relative paths that fail at boot. The generated unit has those defaults done right — and comments explaining every line, because a unit you can read is one you can debug.

🔒 Runs in your browser — nothing is sent anywhere
my-api.service
[Unit]
Description=My API service
# network-online (not network.target) actually waits for a configured
# network — the plain target only means the stack is initialised.
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/node /opt/my-api/server.js
User=myapi
WorkingDirectory=/opt/my-api
Restart=on-failure
RestartSec=5
# Without a start-limit, a crash-looping service retries forever;
# this stops after 5 failures within 100s — systemctl reset-failed to clear.
StartLimitIntervalSec=100
StartLimitBurst=5
# Baseline sandboxing — each line removes a capability the service
# should not need. Drop lines only when the service demonstrably breaks.
NoNewPrivileges=true
ProtectSystem=full
ProtectHome=true
PrivateTmp=true

[Install]
# multi-user.target ≈ 'normal boot, network server' — what enable hooks into.
WantedBy=multi-user.target
Install & watch
sudo tee /etc/systemd/system/my-api.service > /dev/null  # paste the unit
sudo systemctl daemon-reload
sudo systemctl enable --now my-api
systemctl status my-api
journalctl -u my-api -f   # live logs
Learn the theory