Linux Labs

Packages, services, and logs / Stage 5 of 13

Systemd services: state and startup

Not running Starting usually ~20 s
Leave the lesson

Step 2 of 6 · on a machine · 5 min

A unit and its two states

A service has two states, and the machine reports on each one separately. This step covers what they mean.

Services are managed by systemd: it starts them at boot and stops or restarts them on command. Everything it manages is called a unit. A service is a unit whose name ends in .service: cron.service, nginx.service. In systemctl commands you can leave the ending out; to it, cron and cron.service are the same service.

The two states do not depend on each other:

  • active — the service is running now. systemctl is-active prints it: active — running, inactive — stopped, failed — ended with a failure.
  • enabled — the service starts when the system boots; this is called autostart. systemctl is-enabled prints it: enabled — on, disabled — off.

The summary of a service shows both states too:

bash
systemctl status cron --no-pager

On the Loaded line, after the path to the unit file, comes enabled or disabled — that is autostart. The preset: enabled next to it is the autostart setting the Ubuntu package installs the service with; it has no effect on how the service runs. The Active line is about running now: active (running) and the start time. The warning Warning: some journal files were not opened means that student cannot read the service's journal without sudo; the next lesson is about the journal.

Check yourself 1 question

systemctl status nginx prints these lines. What happens to nginx after a reboot?

     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: failed (Result: signal) since Sun 2026-10-18 17:06:37 UTC; 1s ago
  • loaded at the start of the Loaded line means systemd has read the unit file, and its path is right there.

  • failed on the Active line is about running now: nginx ended with a failure. Autostart is on the Loaded line, and it says enabled.

  • After the failure the Loaded line still says enabled: a failure changes running now, autostart stays as it was.

enabled on the Loaded line means systemd starts nginx at boot. failed on the Active line says just that nginx is down right now after a failure.

Key points

  • active means the service runs now, enabled means it starts at boot; neither follows from the other.
  • systemctl is-active and systemctl is-enabled print one state each, systemctl status prints both.
Ubuntu 24.04
Loading…