🎯 Preset
Picking a preset repopulates every field below. Edit afterwards as needed.
📄 Unit basics
🔗 [Unit] dependencies
⚙️ [Service]
🛡️ Hardening
⏱️ [Timer]
🔌 [Socket]
💾 [Mount]
👁️ [Path]
📦 [Install]
📤 Generated unit file
{{ output || '# Fill the form to generate a unit file.' }}
📁 Files needed
-
{{ f.path }}— {{ f.description }}
⚠️ Warnings
- {{ w }}
📖 Directive explanations
- {{ e.directive }}=
- {{ e.meaning }}
ℹ️ About Systemd Unit Generator
What is a systemd unit file?
systemd is the init system used by every modern Linux distribution (Debian, Ubuntu, RHEL,
Fedora, Arch, openSUSE). It supervises long-running services, schedules one-shot jobs, mounts filesystems,
opens sockets, and watches paths for change. Each of these things is described by a unit file
— a plain-text INI file with [Unit], [Service] / [Timer] /
[Socket] / [Mount] / [Path], and [Install] sections.
System-wide unit files live in /etc/systemd/system/; vendor-shipped defaults live in
/lib/systemd/system/ and the user override always wins.
This generator builds a syntactically valid, lint-clean unit file from a small form. Every emitted directive is documented inline so you can see what each line does without consulting the man pages. The output is byte-identical between the browser (instant feedback) and the API (programmatic access) because both share the same TypeScript engine.
Unit types this generator supports
.service— long-running daemon, one-shot bootstrap, forking daemon, Type=notify service that signals readiness viasd_notify(3)..timer— schedule activation of another unit viaOnCalendar=(wall-clock),OnBootSec=, orOnUnitActiveSec=. UsePersistent=trueto backfill missed runs after downtime..socket— socket-activated service. systemd opens the listening socket(s); the matching.serviceonly starts on first connection..mount— filesystem mount point. The filename must match the mount path (e.g./mnt/shared→mnt-shared.mount;systemd-escape -phandles edge cases)..path— fire when a file appears, is modified, or a directory becomes non-empty. Trigger another unit viaUnit=..target— synchronisation point / grouping unit. Use to express "start everything in this group together."
Key directives at a glance
Type=—simple(default),exec,forking(writes a PID file),oneshot(run once and exit),notify(callssd_notify("READY=1")when ready),dbus,idle.ExecStart=— must be an absolute path (optional prefixes:-ignore failures,@override argv[0],!/!!no privilege elevation,:no env-var expansion,+full privileges).Restart=—on-failure,always,on-abnormal,on-watchdog, etc. Combined withType=oneshot+Restart=alwaysthis creates an infinite loop — the generator warns about that.OnCalendar=— wall-clock schedule using the systemd.time grammar. Examples:daily,*-*-* 03:00:00,Mon..Fri 09:00.WantedBy=— adds the unit to a target's.wants/directory when you runsystemctl enable. The usual answer ismulti-user.target.
Hardening — apply these for production
PrivateTmp=true— give the process its own/tmpand/var/tmpnamespace; nothing leaks to or from the global tmp.ProtectSystem=strict— make almost the entire filesystem read-only to the unit. Combine withReadWritePaths=for the writable directories your app actually needs.ProtectHome=true— make/home,/root, and/run/userinaccessible.NoNewPrivileges=true— blocksetuid/ file capabilities from taking effect, so a compromise can never escalate privileges.User=/Group=— never run asrootunless you genuinely must.
After deploying, run systemd-analyze security <unit> to see the security score and
specific recommendations.
Installation workflow
- Place the generated file at
/etc/systemd/system/<name>.service. sudo systemctl daemon-reloadsudo systemctl enable --now <name>.servicesudo systemctl status <name>sudo journalctl -u <name> -f(follow the logs).
Source references
- systemd.unit(5) — generic [Unit] / [Install] directives, dependency model, conditions.
- systemd.service(5) — full [Service] directive reference (Type, ExecStart, Restart, ...).
- systemd.exec(5) — execution context: User, Environment, sandboxing, capabilities, namespaces.
- systemd.timer(5) — [Timer] directives, OnCalendar=, Persistent=.
- systemd.socket(5) — socket activation, Listen*=, Accept=.
- systemd.time(7) — calendar / time-span syntax for OnCalendar= and *Sec= directives.
API Usage Example:
POST /api/tools/linux/systemd-unit-generator
Content-Type: application/json
{
"unitType": "service",
"description": "My web app",
"service": {
"Type": "simple",
"ExecStart": "/usr/bin/node /opt/webapp/server.js",
"User": "webapp",
"Restart": "on-failure"
},
"install": {
"WantedBy": [
"multi-user.target"
]
}
}