Use it to create or change how systemd runs something.
Unit Files
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).
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?
unit file and drop-ins read → merged → daemon-reload loads them → next start uses them
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
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
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 · 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.
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.
systemctl status <unit>— state, main PID, recent log linessystemctl list-units --failed— failed unitsjournalctl -u <unit> -b— the unit's log since bootsystemctl cat <unit>— unit file plus drop-inssystemd-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 enableanddisable. 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
*.confin a<unit>.d/directory are merged after the main file, in alphanumeric order. - Templates:
foo@.servicecan be started asfoo@bar.service, where%iexpands to the instance name.
Conditions and asserts (manual)
| Kind | When 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
| Approach | Use 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/system | Your 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.
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
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
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
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%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%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.
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.
Quick lookup tables
Unit Files operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Unit Files.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | 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. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin 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 chain | unit search path → vendor fragment + generated data + drop-ins → merged effective definition → daemon-reload → activation/restart → runtime state → workload result | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Unit-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 evidence | Correlated 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 result | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It 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 check | Continue 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 boundary | Unit Files |
|---|---|
| Topic path | systemd & Services → Unit Files |
| Runtime state | 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. |
| 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 chain | unit 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 boundary | Unit-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 rule | Prove 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 boundary | Topic-specific reference |
|---|---|
| Precedence | Administrator /etc overrides vendor /usr inputs |
| Override | Drop-ins; list directives may need explicit reset |
| Enablement | Install-time target links, separate from active state |
| Proof | Effective loaded unit after daemon-reload |