systemd Unit Generator
Build a hardened systemd service unit — ExecStart, restart policy, sandboxing directives and [Install] section, downloadable as a .service file.
Build a hardened systemd service unit — rendered locally, downloadable as a .service file.
[Unit] Description=My application service After=network.target [Service] Type=simple ExecStart=/usr/local/bin/myapp --config /etc/myapp.yml WorkingDirectory=/opt/myapp User=myapp Group=myapp Restart=always RestartSec=5 NoNewPrivileges=true ProtectSystem=strict ProtectHome=true PrivateTmp=true ProtectKernelTunables=true ProtectKernelModules=true ProtectControlGroups=true RestrictSUIDSGID=true LockPersonality=true ReadWritePaths=/opt/myapp [Install] WantedBy=multi-user.target
Install: copy to /etc/systemd/system/myapp.service, then systemctl daemon-reload && systemctl enable --now myapp
About systemd Unit Generator
Writing a .service unit from scratch means remembering [Unit]/[Service]/[Install] syntax plus the long list of sandboxing directives. This generator produces a complete, hardened unit from a few fields: ExecStart, user, working directory, environment variables and restart policy.
The hardening toggle adds the usual production baseline — NoNewPrivileges, ProtectSystem=strict, PrivateTmp, ProtectHome, kernel/control-group protections — with ReadWritePaths kept open for the working directory. Everything renders locally and downloads as a .service file.
How to use systemd Unit Generator
- Fill in the unit name, description, ExecStart command and run-as user.
- Set WorkingDirectory, After= dependencies, environment lines and restart policy.
- Keep the hardening option on unless the service needs wider access.
- Download the .service file, place it in /etc/systemd/system, run daemon-reload and enable.
Frequently asked questions
Where does the file go?
System units live in /etc/systemd/system/. After copying, run 'systemctl daemon-reload' then 'systemctl enable --now yourname'.
What does ProtectSystem=strict do?
It mounts the whole filesystem read-only for the service — the generator adds ReadWritePaths for the working directory so the app can still write where it needs to.
Which restart policy should I pick?
'always' for daemons that must stay up, 'on-failure' for batch-like services that may exit cleanly, 'no' if an external supervisor handles restarts.