Glossary

systemd Unit

A unit is systemd's central abstraction: a declarative file that describes something systemd manages. Unit files are INI-style, divided into sections like [Unit] (general metadata and dependencies), [Service] (for service units: how to start the process), and [Install] (how the unit integrates with targets when enabled).

Unit types include:

  • service — a daemon or one-shot process (nginx.service)
  • socket — a socket that activates a service when connected
  • timer — a scheduled trigger (systemd's cron replacement)
  • mount — a filesystem mount
  • target — a grouping of units, like runlevels
  • path — trigger based on filesystem events
  • device — kernel-provided devices

A minimal service unit:

[Unit]
Description=My app
After=network.target

[Service]
ExecStart=/usr/local/bin/myapp
Restart=on-failure
User=myapp

[Install]
WantedBy=multi-user.target

Save to /etc/systemd/system/myapp.service, then systemctl daemon-reload and systemctl enable --now myapp. Unit files compose through dependency directives (Requires=, Wants=, After=, Before=) into the dependency graph systemd uses to bring the system up in parallel.

Related terms: systemd, systemctl

Discussed in:

Also defined in: Textbook of Linux