whatis unit-file
systemd Unit File
Also known as: service file, .service, unit
An INI-style file describing something systemd manages, such as a service, timer, mount, or socket, with its dependencies and settings.
What Is a systemd Unit File?
A .service file has [Unit] (description, ordering), [Service] (the command, user, restart policy, sandboxing), and [Install] (which target enables it) sections. Other types include .timer, .socket, .mount, and .target.
Put your own units in /etc/systemd/system/, run systemctl daemon-reload, then systemctl enable --now name. systemctl edit name creates a drop-in override instead of editing the packaged file.
Example
[Service]
ExecStart=/usr/local/bin/app
Restart=on-failure
User=app Learn more about systemd Unit File
- Writing systemd Service Files Explained Beyond using systemctl to manage existing services, writing your own .service unit file lets you run any script or program as a properly managed systemd service. This guide covers unit file structure, common directives, and enabling a custom service.
- Hardening systemd Services: The Directives That Actually Confine ProtectSystem, PrivateTmp, NoNewPrivileges, and the rest, what each one blocks, and how to use systemd-analyze security to find out how exposed your services are right now.
- systemd Socket Activation Explained How systemd holds the listening socket so a service starts on first connection, why that removes startup ordering problems, and where it does and does not help.
Related tools
- systemd Unit Builder Generate systemd service files with restart policies, dependencies, and sandboxing options.