systemd service file generator

Fill in the command, the user and how the service should restart, and get a ready .service file for systemd, with the path to save it and the systemctl commands to start it now and at every boot. Works for system services and for user services without root.

Install as
One KEY=value per line; lines starting with # are skipped

Save as /etc/systemd/system/myapp.service

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Enter the service name (the file name without .service), a description and the command with its full path.
  2. Set the working directory and, for a system service, the user to run as. Leaving the user empty runs the service as root.
  3. Pick the type and restart policy, add environment variables one per line, and choose the options.
  4. Save the unit file to the path shown, then run the commands: daemon-reload, enable –now, then status and journalctl to check it.

How it works

The unit has three sections:

  • [Unit]: Description and ordering. A system service gets After=network.target, or After= and Wants=network-online.target when it needs the network. A user service gets no network ordering, because a user manager cannot wait for system units.
  • [Service]: Type, User and Group, WorkingDirectory, one Environment=“KEY=value” per variable (with \ and “ escaped), EnvironmentFile, ExecStart, Restart and RestartSec, and with hardening NoNewPrivileges=true and PrivateTmp=true.
  • [Install]: WantedBy=multi-user.target for a system service or default.target for a user service, which is what enable hooks into.

Worked example

The default form (name myapp, Node.js server, user myapp, restart on failure after 5 s, two variables, network-online, hardening) gives:

[Unit]
Description=My app
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=myapp
WorkingDirectory=/opt/myapp
Environment="NODE_ENV=production"
Environment="PORT=3000"
ExecStart=/usr/bin/node /opt/myapp/server.js
Restart=on-failure
RestartSec=5
NoNewPrivileges=true
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Saved as /etc/systemd/system/myapp.service, it is started with sudo systemctl daemon-reload and sudo systemctl enable --now myapp.service.

Tips

  • systemd expands % specifiers in ExecStart and Environment: write %% for a literal percent sign.
  • ExecStart is not run by a shell, so pipes, && and redirects do not work; wrap them as /bin/sh -c ‘…’ or in a script.
  • Keep secrets out of the unit file: put them in an EnvironmentFile readable only by root.
  • After every change to the file, run daemon-reload and restart the service.

Frequently asked questions

Where do I save the file?

A system service goes in /etc/systemd/system/<name>.service (root needed). A user service goes in ~/.config/systemd/user/<name>.service and runs under your account. The path is shown under the unit file.

Which Type should I choose?

simple fits most programs that stay in the foreground: Node.js, Python, Go servers. Use forking only for old daemons that fork into the background and exit, oneshot for scripts that run and finish, and notify for programs that call sd_notify when they are ready.

What is the difference between Restart=on-failure and always?

on-failure restarts the service when it exits with an error code, is killed by a signal or times out, but not after a clean exit. always restarts it in every case. RestartSec sets the pause before a restart.

Why network-online.target instead of network.target?

After=network.target only orders the service after the network stack is set up, not after an address is configured. If your service must connect somewhere at start, network-online.target together with Wants= waits until the network is actually up.

Do I need the full path in ExecStart?

systemd accepts an absolute path or a bare program name, which it looks up in its own fixed search path (such as /usr/local/bin and /usr/bin), not in your shell's PATH. A relative path like ./app is not allowed. Full paths are the safest choice.

Can a user service start at boot?

A user service starts when you log in. To start it at boot without a login, run sudo loginctl enable-linger <your user> once.

More in Developer

All tools in this category: Developer ·Updated November 4, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.