Home › Developer Tools › Systemd Service File Generator

Systemd Service File Generator

Fill in the command, user and restart policy and get a ready-to-use systemd unit file with copy-paste install commands. Options for environment variables, start order, resource limits and sandboxing are included, and common mistakes such as relative paths or shell syntax in ExecStart are flagged.

Last updated:

Service
.service
More commands
Start order & restart
Environment & logging
Security hardening

Generated unit file

    Advertisement
    Advertisement

    How to use the Systemd Service File Generator

    1. Pick an example close to your program and click Load example, or start editing the default Node.js unit.
    2. Enter the unit name, description and ExecStart command with an absolute path, plus the working directory and the user that should run it.
    3. Choose the restart policy and add the units it should start after, environment variables and log name.
    4. Apply hardening with the Basic or Strict preset, then fine-tune individual options.
    5. Copy the unit file or open Install commands, paste them in a terminal and check the service with systemctl status.

    Anatomy of a unit file

    A service unit is a plain text file with three sections. Directives are case-sensitive, and each belongs to one section:

    SectionDirectiveWhat it does
    [Unit]Description=Human-readable name shown by systemctl status.
    After= / Wants=Start order and weak dependency. After alone does not pull a unit in.
    Requires=Strong dependency: if the required unit stops, this one stops too.
    StartLimitIntervalSec=, StartLimitBurst=Give up after too many restarts in a time window.
    [Service]Type=How systemd knows the service has started (simple, exec, forking, notify, oneshot, idle).
    ExecStart=The command to run. Not a shell: no pipes or redirects.
    User= / Group=Account the process runs as (root if omitted in system services).
    WorkingDirectory=Current directory of the process.
    Restart= / RestartSec=When to restart automatically and how long to wait first (default 100 ms).
    Environment= / EnvironmentFile=Variables for the process; a leading - on the file path makes it optional.
    [Install]WantedBy=Target that pulls the service in when it is enabled, usually multi-user.target.

    Everyday systemctl and journalctl commands

    CommandPurpose
    sudo systemctl daemon-reloadReload unit files after creating or editing them.
    sudo systemctl enable --now appStart at boot and start right now.
    sudo systemctl restart app / reload appRestart the process, or run ExecReload (config reload without downtime).
    systemctl status appState, main PID, memory and the last log lines.
    journalctl -u app -fFollow the service log live; add --since "1 hour ago" to filter.
    sudo systemctl edit appCreate a drop-in override instead of changing the original file.
    systemd-analyze verify app.serviceCheck a unit file for unknown directives and missing files.
    systemd-analyze security appShow the sandboxing exposure score and which options would improve it.

    Tips

    • Escape special characters. In unit files % starts a specifier (for example %n is the unit name), so write %% for a literal percent sign. $VAR and ${VAR} in ExecStart are replaced from Environment, and $$ is a literal dollar.
    • Log to stdout. Anything the program prints goes to the journal automatically; there is no need for log files unless you want them.
    • Harden step by step. Start with Basic, restart the service and check its logs, then try Strict. If the app needs to write somewhere, add that folder to ReadWritePaths.
    • Prefer timers to cron for systemd hosts. A oneshot service plus a .timer unit gets logging, dependencies and missed-run catch-up for free.

    Frequently asked questions

    Where do I put a systemd service file?

    System services you create go in /etc/systemd/system/name.service. Per-user services go in ~/.config/systemd/user/name.service. After adding or changing a file, run systemctl daemon-reload (or systemctl --user daemon-reload) so systemd reads it.

    How do I make a service start at boot?

    The [Install] section with WantedBy=multi-user.target tells systemd where to hook the service in. Run sudo systemctl enable --now name.service to create that link and start it immediately. User services use WantedBy=default.target, and loginctl enable-linger keeps them running when you are logged out.

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

    on-failure restarts the service only when it exits with a non-zero code, is killed by a signal, times out or trips the watchdog. always also restarts it after a clean exit. Neither restarts a service you stop with systemctl stop. If restarts happen more often than StartLimitBurst times within StartLimitIntervalSec (5 in 10 seconds by default), systemd gives up.

    Why does my ExecStart command fail when it works in the terminal?

    systemd runs the command directly, without a shell and without your login environment. Use absolute paths, avoid pipes, redirects, && and ~, set WorkingDirectory and Environment explicitly, or wrap the command in /bin/sh -c '...'. Check journalctl -u name.service for the exact error.

    Which Type should I choose?

    Use simple (or exec) for programs that stay in the foreground, which covers most modern apps. Use forking only for old daemons that fork into the background, ideally with PIDFile. notify is for programs that call sd_notify when ready, and oneshot is for scripts that run once and exit, often with RemainAfterExit=yes.

    How do I pass environment variables or secrets?

    Use Environment=KEY=value lines (quote the whole assignment when the value has spaces) for ordinary settings. For passwords and tokens use EnvironmentFile=/etc/name/env with permissions 600, because unit files are readable by every user on the system.

    What do the hardening options do?

    They sandbox the service: NoNewPrivileges blocks privilege escalation, PrivateTmp gives it its own /tmp, ProtectSystem and ProtectHome make system folders read-only or hidden, and the Protect/Restrict options block kernel tuning, module loading and similar actions. Run systemd-analyze security name.service to see an exposure score, and test the service after each change.

    Are all the tools on FreeToolCabin tested for quality and accuracy?

    Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

    Related tools

    Nginx Config GeneratorBuild an nginx server block: static site, SPA, reverse proxy or PHP, with SSL, gzip and redirects.Cron Expression GeneratorBuild crontab schedules visually, read them in plain English and see the next run times.Dockerfile GeneratorGenerate a production Dockerfile and .dockerignore for Node, Python, Go or a static nginx site.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.QR Code GeneratorMake QR codes for links, Wi-Fi, email and more.Barcode GeneratorCreate Code 128, EAN-13, UPC-A, EAN-8, Code 39 and ITF-14 barcodes as PNG or SVG.UUID GeneratorGenerate UUID v4 and v7 / GUIDs in bulk and copy or download them.Schema Markup Generator (JSON-LD)Create JSON-LD structured data for FAQ, Product, Article and more.Htaccess & Nginx Redirect GeneratorBuild 301 redirects for .htaccess, Nginx and Netlify or Cloudflare _redirects.Fake Data GeneratorGenerate mock data as JSON, CSV or SQL.Random String GeneratorGenerate secure random strings and tokens in bulk with any length and character set.API Key GeneratorCreate secure API keys and secrets with prefixes, checksums and SHA-256 hashes for storage.MIME Type LookupFind the MIME type for any file extension, or the extensions for a MIME type, in 400+ entries.URL Slug GeneratorTurn titles into clean, SEO-friendly URL slugs: accents, stop words, separators and bulk lines.JSON Schema GeneratorTurn sample JSON into a draft 2020-12 JSON Schema with types, required fields and formats.Gitignore GeneratorBuild a .gitignore from 50+ templates for languages, frameworks, IDEs and OS, merged and deduped.License GeneratorCreate a LICENSE file for MIT, Apache, GPL, BSD, ISC, MPL or Unlicense with your name and year.ULID GeneratorGenerate sortable ULIDs and UUID v7 in bulk, monotonic option, and decode their timestamps.Htpasswd GeneratorCreate .htpasswd entries with bcrypt, APR1-MD5 or SHA-1 for Apache and Nginx basic auth.Placeholder Image GeneratorCreate placeholder images in any size, color and text as PNG, JPG, WebP, SVG or data URI.Ads.txt GeneratorCreate or validate ads.txt and app-ads.txt files: seller lines, cert IDs and variables.Docker Run to Compose ConverterConvert docker run commands to docker-compose.yml, or a compose file back to docker run.HTML Boilerplate GeneratorTick the options you need and get a clean HTML5 starter template with meta, OG tags and CSS reset.JSON to Zod SchemaInfer a Zod (or Yup) schema from sample JSON with optional, nullable and z.infer types.Linux Commands Cheat SheetSearchable Linux and bash command reference with flags explained, examples and copy buttons.LLMs.txt GeneratorBuild an llms.txt file for AI crawlers: summary and link sections, import from your sitemap.Nano ID GeneratorGenerate secure Nano IDs with custom alphabet, length and count, plus a collision calculator.OpenAPI / Swagger ViewerView OpenAPI 2/3 JSON or YAML as interactive API docs with validation and an endpoint list.package.json GeneratorFill a form and get a valid, npm-ready package.json with scripts, dependencies and checks.PKCE Code Challenge GeneratorGenerate an OAuth 2.0 PKCE code_verifier and S256 code_challenge, build auth URLs, verify pairs.README GeneratorFill in a form and get a polished README.md with badges, install, usage and license, live preview.Regex GeneratorBuild regular expressions visually from blocks or presets (email, date, phone) and test them live.Commit Message GeneratorBuild Conventional Commit messages with type, scope, body, breaking change and issue refs.Database Schema DesignerDesign tables and relationships visually, then export SQL for MySQL, PostgreSQL or SQLite.Docker Compose GeneratorBuild a docker-compose.yml with a form: services, ports, volumes, env, healthchecks and presets.Dummy File GeneratorCreate test files of an exact size in KB, MB or GB with zeros, random bytes or text.FFmpeg Command GeneratorPick a task and options, get the exact ffmpeg command with every flag explained.Folder Tree GeneratorTurn a local folder or an indented list into an ASCII directory tree for your README.ESLint Config GeneratorGenerate a flat eslint.config.js for JavaScript, TypeScript, React or Node with rule presets.Git Branch Name GeneratorTurn a ticket ID and title into a clean, valid git branch name like feature/PROJ-12-add-login.GitLab CI Config GeneratorGenerate a .gitlab-ci.yml with stages, jobs, images, cache, artifacts and rules from templates.Jinja2 Template TesterRender Jinja2 templates with YAML or JSON variables using real Jinja2, with clear error lines.JSON Schema Mock Data GeneratorGenerate realistic sample JSON from a JSON Schema: formats, patterns, $ref, seeds and counts.Kubernetes Secret GeneratorCreate Kubernetes Secret YAML from key/value pairs or .env with auto base64, or decode one.Kubernetes YAML ValidatorValidate Kubernetes manifests against the API schema of a chosen version, with error paths.Prettier Config GeneratorToggle Prettier options, preview formatted code live and copy your .prettierrc file.Quartz Cron GeneratorBuild and explain Quartz and Spring cron expressions with seconds, ?, L, W and #, plus next fire times.README Badge GeneratorCreate Shields.io-style README badges for license, version, build and custom labels.tsconfig.json GeneratorBuild a tsconfig.json with target, module, strict checks and path aliases, each option explained.Access Log AnalyzerAnalyze Apache and Nginx access logs: top URLs, IPs, status codes, bots and traffic charts.Regex String GeneratorGenerate random test strings that match any regular expression, checked against the real regex.ASCII Table GeneratorTurn CSV or pasted cells into plain-text tables: MySQL, Markdown, Unicode box and reST styles.GitHub Actions Workflow GeneratorBuild a GitHub Actions CI workflow: triggers, matrix, caching, tests, Pages or Docker deploy.Kubernetes YAML GeneratorGenerate Deployment, Service, Ingress, ConfigMap, Secret and HPA manifests with safe defaults.Markdown TOC GeneratorGenerate a linked table of contents from Markdown headings with GitHub-style anchors.OpenAPI EditorEdit OpenAPI/Swagger YAML or JSON side by side with live API docs, validation and download.OpenAPI ValidatorValidate OpenAPI 3.0/3.1 and Swagger 2.0 specs: schema errors, broken $refs, line numbers.Pivot Table MakerBuild pivot tables from CSV or Excel by drag and drop: sum, count, average, charts, export.SQL Query BuilderBuild SELECT queries visually: joins, filters, GROUP BY, ORDER BY and LIMIT, as clean SQL.Truth Table GeneratorType a logic expression and get its full truth table, minterms and canonical DNF/CNF.TypeScript PlaygroundWrite TypeScript with live type checking, see the compiled JavaScript and run it in your browser.Article Schema GeneratorCreate Article, BlogPosting or NewsArticle JSON-LD with headline, authors, dates and images.Event Schema GeneratorCreate Event JSON-LD with dates, venue or online location, tickets, organizer and performers.Google Search Query BuilderBuild advanced Google searches with site:, filetype:, intitle:, exact phrases and date operators.HowTo Schema GeneratorCreate HowTo JSON-LD with steps, tools, supplies, total time and cost, then copy it.Htaccess GeneratorBuild an Apache .htaccess file: HTTPS, www, gzip, caching, error pages, IP blocks, hotlinks.HTML Email Template BuilderDrag and drop blocks to build a responsive, table-based HTML email with inline styles.Organization Schema GeneratorCreate Organization JSON-LD with logo, URL, contact points, address and social profiles.
    See all 85 Code Generators & Builders →