Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Unit Files

Direct answer

A unit file is an INI-style file describing a unit: [Unit] (description, dependencies), a type section such as [Service] (ExecStart, User, Restart) and [Install] (which target enables it).

When to use this

Use it to create or change how systemd runs something.

First 30 seconds

1. systemctl cat <unit> — effective file and drop-ins.

2. systemd-analyze verify <unit> — syntax errors?

3. Change with systemctl edit <unit>.

4. systemctl daemon-reload, then restart.

5. systemctl show <unit> -p <Setting> — value applied?

Operational verification

unit file and drop-ins read → merged → daemon-reload loads them → next start uses them

Evidence · next step

For systemd & Services → Unit Files, continue with the first unproven Topic check: Capture fragment path and all active drop-in paths for the exact unit. If that boundary is healthy, advance to the adjacent check: Compare vendor definition with administrator overrides and effective manager properties. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it to create or change how systemd runs something.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

7 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

unit search path → vendor fragment + generated data + drop-ins → merged effective definition → daemon-reload → activation/restart → runtime state → workload result

Healthy evidence: the expected fragment/drop-ins form the intended effective definition, manager state is refreshed and runtime/workload behavior matches the change.

Step 2 Verification and output interpretation Verify boundary

Existing fast checks for this Topic. - Capture fragment path and all active drop-in paths for the exact unit.

  • Compare vendor definition with administrator overrides and effective manager properties.
  • Run syntax/verification where appropriate, then reload manager configuration deliberately.
  • Verify the service lifecycle and application behavior after applying the effective change.

Verification chain. unit search path → vendor fragment + generated data + drop-ins → merged effective definition → daemon-reload → activation/restart → runtime state → workload result

Step 3 Specialized verification Verify boundary

Use the effective-unit output to identify the canonical fragment and all loaded drop-ins, and compare it with filesystem paths only after that. Check enablement separately from active state. After editing, show daemon-reload occurred by re-reading the effective unit and then perform the minimum reload/restart needed for the managed resource. If precedence is unexpected, inspect search paths, aliases and generated units rather than deleting files until the source is identified.

Step 4 Commands Verify boundary
systemctl edit app          # drop-in
systemctl cat app
systemd-analyze verify /etc/systemd/system/app.service
Step 5 Failure modes and next checks Narrow the fault

Suspicious evidence: operators edit a file but never show which fragment/drop-in is loaded or whether daemon-reload occurred.

Step 6 Special cases and limits Narrow the fault

A syntactically valid unit file can be ignored because a higher-precedence file or drop-in wins. Enablement is boot/target linkage, not current health. daemon-reload updates systemd’s model but does not force already-running applications to consume new daemon-specific configuration. Package upgrades may replace vendor files while /etc overrides continue to win. Keep file ownership, manager load state, enablement and service runtime as separate facts.

Step 7 Common mistakes Narrow the fault
  • Editing vendor unit files.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

Do not edit package files in /usr/lib/systemd/system — create a drop-in with systemctl edit <unit> or a full copy in /etc/systemd/system. Run systemctl daemon-reload after changing files. To clear a list setting such as ExecStart in a drop-in, set it empty first.

Key checks
  • systemctl status <unit> — state, main PID, recent log lines
  • systemctl list-units --failed — failed units
  • journalctl -u <unit> -b — the unit's log since boot
  • systemctl cat <unit> — unit file plus drop-ins
  • systemd-analyze verify <unit> — unit file errors
ReferenceWhat it is1 section · depth on demand

Core model

Identify the fragment path and all drop-ins that contribute to the loaded unit. Prefer override/drop-in semantics over editing vendor files when maintainability matters. After file changes, distinguish disk content from manager-loaded content and verify the effective properties before restarting or reloading the service.

ReferenceImportant terms & boundaries6 sections · depth on demand

What this shows and what it does not

Unit-file evidence shows persistent configuration sources, not what systemd currently has loaded or whether the service works with the new definition.

daemon-reload owns manager refresh; Services owns lifecycle behavior.

In depth

Writing unit files: sections, drop-ins and templates

A unit file is an INI-style file with sections. The systemd.unit(5) manual page covers the generic parts:

  • [Unit] holds the description, documentation, dependencies and conditions.
  • [Install] is read only by systemctl enable and disable. systemd itself ignores it during normal operation.
  • Type-specific settings go in their own section, such as [Service], [Timer] or [Socket].
  • Drop-ins: files named *.conf in a <unit>.d/ directory are merged after the main file, in alphanumeric order.
  • Templates: foo@.service can be started as foo@bar.service, where %i expands to the instance name.

Conditions and asserts (manual)

KindWhen the check fails
Condition...=The start is silently skipped
Assert...=The start job fails, with a logged error

Neither puts the unit in the "failed" state. A skipped unit shows "condition failed" in systemctl status.

Override strategies

ApproachUse when
systemctl edit <unit> (drop-in)Changing a few settings on a packaged unit
systemctl edit --full <unit>The whole unit needs rewriting; a copy goes to /etc
A new file in /etc/systemd/systemYour own services

Some list settings, such as ExecStart=, must be cleared before they're replaced in a drop-in. An empty ExecStart= line first, then the new one. Otherwise the drop-in adds a second command, and the unit fails to load.

A template for several instances

host$ cat /etc/systemd/system/queue-worker@.service
[Unit]
Description=Queue worker %i
After=network-online.target
Wants=network-online.target
ConditionPathExists=/etc/queue-worker/%i.conf

[Service]
Type=exec
User=worker
ExecStart=/usr/local/bin/queue-worker --config /etc/queue-worker/%i.conf
Restart=on-failure

[Install]
WantedBy=multi-user.target
host$ sudo systemctl enable --now queue-worker@billing queue-worker@reports
host$ systemctl list-units 'queue-worker@*' --no-legend
host$ sudo systemctl edit nginx
[Service]
ExecStart=
ExecStart=/usr/sbin/nginx -g 'daemon off; worker_processes 4;'
host$ systemctl cat nginx | grep -n ExecStart

ConditionPathExists in the example

The condition makes an instance without a configuration file skip quietly instead of failing. That's convenient when a template is enabled more broadly than the configuration exists.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

Unit Files is part of systemd & Services → Unit Files. Unit Files are the persistent or generated definitions systemd loads from its search path, with vendor files, administrator overrides and drop-ins combining into an effective unit configuration.

Topic-specific state model. Unit Files are the persistent or generated definitions systemd loads from its search path, with vendor files, administrator overrides and drop-ins combining into an effective unit configuration.

Interpretation rule. - Unit file on disk ≠ effective loaded unit definition.

  • Vendor file edit ≠ durable customization across package upgrades.
  • Drop-in exists ≠ it applies to the unit/name/instance you intended.
  • Syntax-valid unit file ≠ service behavior is correct.

Specialized mechanics

Unit files are persistent inputs to systemd’s loaded manager model. Search paths have precedence, and drop-ins can extend or reset list-valued directives depending on syntax. Vendor fragments under /usr and administrator configuration under /etc can coexist; generators can also synthesize transient units or dependencies at manager reload/boot. What exists on disk is therefore not necessarily what PID 1 currently has loaded. Masking resolves a unit name to /dev/null and therefore overrides ordinary enablement or dependency selection; aliases and template instances can also change which fragment is selected for a requested unit name.

Quick reference

Unit files live in /usr/lib/systemd/system (packages), /etc/systemd/system (admin, wins), and /run/systemd/system (runtime). Override packaged units with drop-ins instead of editing them:

systemctl edit nginx              # creates /etc/systemd/system/nginx.service.d/override.conf
[Service]
LimitNOFILE=65536
Restart=on-failure

systemctl cat nginx                # effective unit incl. drop-ins
systemd-delta --type=overridden

A minimal service:

[Unit]
Description=Report worker
After=network-online.target
Wants=network-online.target
[Service]
User=report
ExecStart=/opt/report/bin/worker
Restart=on-failure
NoNewPrivileges=yes
ProtectSystem=strict
ReadWritePaths=/var/lib/report
[Install]
WantedBy=multi-user.target
Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. Unit-file evidence shows persistent configuration sources, not what systemd currently has loaded or whether the service works with the new definition.

ReferenceConfiguration & state2 sections · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. Unit Files owns persistent systemd configuration composition. daemon-reload owns manager refresh; Services owns lifecycle behavior.

Specialized lifecycle

Prefer systemctl edit-style administrator drop-ins for local overrides and preserve vendor files for package ownership. When replacing list directives, use the directive’s documented reset behavior before adding the new value. Enablement creates dependency links according to [Install] metadata; it does not alter [Service] execution semantics and does not automatically start a unit. Run daemon-reload after changing unit-file inputs and understand that some generator results may depend on boot or manager reload.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in systemd & Services → Unit Files. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://systemd.io/ · confidence 94%
2026-09-13 · vendor docsystemd current

Authoritative Linux project/vendor documentation reviewed for bounded reference claims: unit-file search paths, overrides, drop-ins and daemon-reload boundary. Documentation-based technical verification only; not lab or production-runtime proof. The schema vendor_doc method is used for authoritative project/vendor documentation; deployment applicability remains separate evidence.

Basis: https://man7.org/linux/man-pages/man5/systemd.unit.5.html · confidence 93%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
systemd unit filessystemd drop-insunit override linuxsystemd fragment path
Embedded reference data

Quick lookup tables

Unit Files operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Unit Files.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateUnit Files are the persistent or generated definitions systemd loads from its search path, with vendor files, administrator overrides and drop-ins combining into an effective unit configuration.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin host/container + timestamp → identify exact process or unit → capture PID plus start identity and cgroup/unit → resolve effective unit fragment + drop-ins → inspect dependency/order transaction → record systemd job result → verify process/cgroup and active/sub state → prove application readiness → repeat the original workload test.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainunit search path → vendor fragment + generated data + drop-ins → merged effective definition → daemon-reload → activation/restart → runtime state → workload resultTrace requested/configured state through effective state to the observed workload result.
Failure boundaryUnit-file evidence proves persistent configuration sources, not what systemd currently has loaded or whether the service works with the new definition.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux process/systemd evidence can establish this proof path: unit search path → vendor fragment + generated data + drop-ins → merged effective definition → daemon-reload → activation/restart → runtime state → workload resultUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured process, manager, unit, dependency, runtime or application scope. Unit-file evidence proves persistent configuration sources, not what systemd currently has loaded or whether the service works with the new definition.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven boundary: reacquire stable process identity, inspect effective loaded unit configuration and dependency/job state, correlate process/cgroup plus journal evidence, then run the original readiness/workload test before changing additional settings.Continue to the next unresolved boundary while preserving the original test condition.

Unit Files · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundaryUnit Files
Topic pathsystemd & Services → Unit Files
Runtime stateUnit Files are the persistent or generated definitions systemd loads from its search path, with vendor files, administrator overrides and drop-ins combining into an effective unit configuration.
Fast checks- Capture fragment path and all active drop-in paths for the exact unit. - Compare vendor definition with administrator overrides and effective manager properties. - Run syntax/verification where appropriate, then reload manager configuration deliberately. - Verify the service lifecycle and application behavior after applying the effective change.
Verification chainunit search path → vendor fragment + generated data + drop-ins → merged effective definition → daemon-reload → activation/restart → runtime state → workload result Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundaryUnit-file evidence proves persistent configuration sources, not what systemd currently has loaded or whether the service works with the new definition. Boundary chain: unit config/drop-ins → dependency/order/condition → exec/process → readiness/active state → owned socket/file/device → dependent client/workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.

Unit Files · specialized operational reference

Topic-specific Linux mechanics, lifecycle, proof path and failure-boundary lookup.

Operational boundaryTopic-specific reference
PrecedenceAdministrator /etc overrides vendor /usr inputs
OverrideDrop-ins; list directives may need explicit reset
EnablementInstall-time target links, separate from active state
ProofEffective loaded unit after daemon-reload
Confirmation

Confirm action

Continue?