Use it when a service fails to start, crashes, restarts in a loop, or runs with the wrong settings.
Services
A systemd service unit (.service) runs and supervises a process: how to start it (ExecStart), as which user, how to restart it, and what it depends on.
1. systemctl status <svc> — active, failed, or activating (auto-restart)?
2. journalctl -u <svc> -b -e — the actual error.
3. Config test: nginx -t, sshd -t, apachectl configtest…
4. Port in use? ss -ltnp | grep :<port>.
5. Fix, then systemctl restart <svc> and recheck.
service started → ExecStart runs as User= → main process stays up → systemd restarts it per policy → logs to the journal
For systemd & Services → Services, continue with the first unproven Topic check: Inspect effective service Type, ExecStart/ExecStartPre/Post, restart policy and environment/credentials. If that boundary is healthy, advance to the adjacent check: Correlate systemd job result with MainPID/cgroup and journal events. 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.
systemctl is-active <unit>Primary Commands
Configuration and operational commands for this Topic.
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
service unit definition → preconditions/ExecStart → service-Type readiness semantics → MainPID/cgroup → active/sub state → application readiness → dependent workload result
Healthy evidence: configured service lifecycle completes as intended, process/cgroup identity is correct and application-level readiness remains stable without unintended restart loops.
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Inspect effective service Type, ExecStart/ExecStartPre/Post, restart policy and environment/credentials.
- Correlate systemd job result with MainPID/cgroup and journal events.
- Interpret active/sub state according to the configured service Type.
- Test the application protocol/workload rather than stopping at systemd state.
Verification chain. service unit definition → preconditions/ExecStart → service-Type readiness semantics → MainPID/cgroup → active/sub state → application readiness → dependent workload result
Step 3 Specialized verification Verify boundary
Inspect service type, result, exit status, MainPID and cgroup processes, then correlate the journal around the transition. Confirm the executable and effective environment/credentials when startup differs from an interactive shell. For a reload, show that the daemon acknowledged or consumed configuration rather than merely that systemctl returned success. Finish with the listener, health endpoint or original client transaction because “active (running)” only shows the supervision layer.
Step 4 Commands Verify boundary
systemctl status app
systemctl show app -p ExecStart,Restart
Step 5 Failure modes and next checks Narrow the fault
Suspicious evidence: active state is accepted despite failed readiness, wrong Type semantics or repeated crash/restart cycles.
Step 6 Special cases and limits Narrow the fault
Restart loops can make a service appear intermittently active while never becoming usable. systemd may classify the process exit correctly even when the root cause is missing files, permissions, network dependencies or invalid application config. Type=forking and PID files introduce identity races if the daemon contract is wrong. Service state does not show dependency readiness, and application readiness does not show persistence across boot. Separate service supervision from application health.
Step 7 Common mistakes Narrow the fault
- Services without
Restart=policy.
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.
Read the journal, not just status. Common causes: wrong path in ExecStart, missing permissions for User=, a port already in use, a config error (test with the program's own check, e.g. nginx -t). Restart=on-failure hides crashes — check the restart count.
systemctl show <svc> -p NRestarts— how often it restartedsystemctl 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
Interpret service state through its configured Type and lifecycle. For simple/exec/forking/oneshot/notify-style services, the meaning of “started” differs; capture ExecStart result, MainPID/cgroup, active/sub state and application readiness separately. Restart loops can make a service appear intermittently active while the workload remains broken.
ReferenceImportant terms & boundaries6 sections · depth on demand
What this shows and what it does not
Service-unit state shows systemd lifecycle observations according to Type; it does not automatically show the application is accepting correct work.
In depth
Service types and restart behaviour
A service unit tells systemd how to start a program, and also when to consider it started. That second part is what Type= decides. The systemd.service(5) manual page defines the types:
- simple (the default when ExecStart= is set): started as soon as the process is forked.
- exec: started once the binary has actually executed, so a missing binary or user causes a start failure.
- forking: started when the original process exits after daemonising. The manual discourages it.
- oneshot: started when the main process has exited. It's normally combined with
RemainAfterExit=yes. - notify: started when the service sends
READY=1via sd_notify. - dbus: started when the service takes its bus name.
Choosing a type
| Program behaviour | Type |
|---|---|
| Runs in the foreground, no readiness signal | exec (better error reporting than simple) |
| Supports sd_notify | notify |
| A script that does a job and exits | oneshot (+ RemainAfterExit=yes if it "sets something up") |
| An old daemon that forks into the background | forking + PIDFile= (prefer a foreground option if one exists) |
Restart and timeouts (manual)
| Setting | Default | Note |
|---|---|---|
Restart= | no | Values: on-success, on-failure, on-abnormal, on-watchdog, on-abort, always |
RestartSec= | 100 ms | Pause before a restart |
TimeoutStartSec= | Manager default | Disabled by default for oneshot |
TimeoutStopSec= | Manager default | Then SIGKILL |
| Rate limiting | StartLimitIntervalSec= / StartLimitBurst= | Stops restart loops |
Command prefixes
- ignores a failing command, and + runs it with full privileges. ! elevates only the user and group settings.
host$ cat /etc/systemd/system/report-api.service
[Unit]
Description=Report API
After=network-online.target
Wants=network-online.target
[Service]
Type=exec
User=reportapi
ExecStartPre=/usr/local/bin/report-api --check-config
ExecStart=/usr/local/bin/report-api --listen 127.0.0.1:8080
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
host$ sudo systemctl daemon-reload && sudo systemctl enable --now report-api
host$ systemctl show report-api -p Type,Restart,NRestarts,ExecMainStatus
Why exec instead of simple
With simple, systemctl start reports success even if the binary path is wrong. The failure only shows up afterwards. With exec, the start command itself fails, which is what you want in deployment scripts.
Documented example, not captured output.
How it works at runtime
Services is part of systemd & Services → Services. Service units describe processes or service lifecycles managed by systemd, including start commands, service Type, restart policy, environment, credentials, dependencies and readiness semantics.
Topic-specific state model. Service units describe processes or service lifecycles managed by systemd, including start commands, service Type, restart policy, environment, credentials, dependencies and readiness semantics.
Interpretation rule. - Service started ≠ service ready.
- active (exited) ≠ daemon process healthy; it can be valid for oneshot semantics.
- MainPID exists ≠ all worker processes or application dependencies are healthy.
- Automatic restart ≠ root cause fixed.
Specialized mechanics
A .service unit defines how systemd starts, tracks and stops a workload. Type= changes the readiness contract: simple/exec, forking, oneshot, notify and dbus services become “started” under different conditions. MainPID, cgroup membership, Restart= policy, watchdog behavior and exit-status classification determine supervision. Child processes can remain in the cgroup even when the original launcher exits, and readiness can be application-specific beyond systemd’s state machine.
Quick reference
Service management and inspection:
systemctl status nginx --no-pager -l
systemctl show nginx -p MainPID,ActiveState,SubState,NRestarts,ExecMainStatus,MemoryCurrent
systemctl is-active nginx; systemctl is-enabled nginx; systemctl is-failed nginx
systemctl kill -s HUP nginx
systemctl --failed
systemctl reset-failed
Service Type= matters: simple/exec (main process is the service), forking (legacy daemons, need PIDFile=), notify (service signals readiness via sd_notify), oneshot (runs to completion, often with RemainAfterExit=yes). A wrong type causes "start timed out" or services considered started too early.
Limits and how it fails
Primary failure point. Service-unit state shows systemd lifecycle observations according to Type; it does not automatically show the application is accepting correct work.
ReferenceConfiguration & state2 sections · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. Services owns systemd service-unit lifecycle semantics. Application-specific health checks, networking and storage dependencies remain with their owners.
Specialized lifecycle
Treat ExecStart/ExecReload, user/group, environment, working directory, sandboxing, restart policy and dependencies as part of a single service execution contract. Validate daemon-native configuration separately before requesting reload/restart. Use EnvironmentFile only with the security and quoting semantics understood by the service; it is not a shell script. For local unit changes use drop-ins and document whether the application supports true reload or requires restart to consume settings.
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 → Services. 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: service supervision, service types, process state and restart boundaries. 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.service.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
Services operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Services.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | Service units describe processes or service lifecycles managed by systemd, including start commands, service Type, restart policy, environment, credentials, dependencies and readiness semantics. | 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 | service unit definition → preconditions/ExecStart → service-Type readiness semantics → MainPID/cgroup → active/sub state → application readiness → dependent workload result | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Service-unit state proves systemd lifecycle observations according to Type; it does not automatically prove the application is accepting correct work. | 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: service unit definition → preconditions/ExecStart → service-Type readiness semantics → MainPID/cgroup → active/sub state → application readiness → dependent 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. Service-unit state proves systemd lifecycle observations according to Type; it does not automatically prove the application is accepting correct work. | 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. |
Services · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | Services |
|---|---|
| Topic path | systemd & Services → Services |
| Runtime state | Service units describe processes or service lifecycles managed by systemd, including start commands, service Type, restart policy, environment, credentials, dependencies and readiness semantics. |
| Fast checks | - Inspect effective service Type, ExecStart/ExecStartPre/Post, restart policy and environment/credentials. - Correlate systemd job result with MainPID/cgroup and journal events. - Interpret active/sub state according to the configured service Type. - Test the application protocol/workload rather than stopping at systemd state. |
| Verification chain | service unit definition → preconditions/ExecStart → service-Type readiness semantics → MainPID/cgroup → active/sub state → application readiness → dependent 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 | Service-unit state proves systemd lifecycle observations according to Type; it does not automatically prove the application is accepting correct work. 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. |
Services · specialized operational reference
Topic-specific Linux mechanics, lifecycle, proof path and failure-boundary lookup.
| Operational boundary | Topic-specific reference |
|---|---|
| Readiness | Depends on Type= and daemon behavior |
| Ownership | MainPID + unit cgroup |
| Change boundary | Daemon config validation → reload/restart |
| Proof | Stable supervised state + original client workload |