Linux – What Are Systemd Runtime Unit Files For?

filesinitlinuxsystemd

The documentation I have read on systemd unit files states that unit files can be found in three locations on the filesystem:

  1. /etc/systemd/system/: system unit files
  2. /run/systemd/system/: runtime unit files
  3. /lib/systemd/system/ (also sometimes /usr/lib/systemd/system/): default unit files for packages

I understand that system unit files are for (possibly user-configured) system daemons. I also understand that default package unit files are unit files that come along with package installs that provide sane defaults.

However, I cannot find documentation that explains the purpose of runtime unit files. What are runtime unit files for? Might I, as a sysadmin, ever create one? What are some examples of problems that might be solved with runtime unit files? Why do runtime unit files take precedence over package unit files, but not over system unit files?

Best Answer

Historically, runtime unit files are intended for machine-generated units. They are supposed to override corresponding vendor units (if any), but are designed to allow user overrides, hence the defined precedence.

Nowadays I think they’ve largely been supplanted by transient units generated using the bus API; these don’t appear as files anywhere.