Linux

systemd Unit Generator

Generate a systemd unit file for your service: command, dedicated user, restart policy and installation commands.

Use a dedicated unprivileged account.

Never put secrets here: use EnvironmentFile with 600 permissions.

How it works

A systemd unit describes how to start, stop and supervise a service. The file goes in /etc/systemd/system/my-app.service.

Best practices: run under a dedicated non-privileged user, set Restart=on-failure, avoid secrets in Environment (use EnvironmentFile with a file in 600), and enable the service with systemctl enable --now.

Examples

Python API

Complete unit ready to install.

namenettools-api
descriptionAPI NetTools
exec_start/opt/nettools/.venv/bin/uvicorn app.main:app --host 127.0.0.1 --port 8000
usernettools
restarton-failure
working_dir/opt/nettools
environment
wanted_bymulti-user.target
Load this example

Frequently asked questions

Where should the unit file go?

/etc/systemd/system/name.service, then systemctl daemon-reload and systemctl enable --now name.

How do you check the logs?

journalctl -u name -f, or --since '10 min ago' for recent history.

Is Restart=always a good idea?

For a critical service, yes, but it masks repeated crashes: combine it with restart monitoring (StartLimitBurst).