Software & OS

systemctl Commands: Start, Stop, Enable and Check Linux Services

systemctl is the command that controls services on Linux distributions that use systemd, which includes Ubuntu, Debian, Fedora, RHEL and Arch. The everyday set is sudo systemctl start|stop|restart nginx to control a service now, sudo systemctl enable --now nginx to make it start at boot, and systemctl status nginx to see whether it is running and why not.

Replace nginx with your service name in every command. Commands that change state need sudo; commands that only read state don't.

The systemctl commands you'll use most

CommandWhat it does
systemctl start nginxStart the service now
systemctl stop nginxStop it now
systemctl restart nginxStop then start. Starts it if it wasn't running.
systemctl reload nginxAsk the service to re-read its own config without stopping. Only works if the service supports it.
systemctl reload-or-restart nginxReload if supported, otherwise restart
systemctl try-restart nginxRestart only if it is already running; do nothing otherwise
systemctl enable nginxStart automatically at boot (does not start it now)
systemctl enable --now nginxEnable and start in one step
systemctl disable nginxDon't start at boot (does not stop it now; add --now to also stop)
systemctl mask nginxLink the unit to /dev/null so nothing can start it, even manually or as a dependency
systemctl unmask nginxUndo mask
systemctl status nginxState, main PID, memory and the last log lines
systemctl daemon-reloadReload unit files after you edit or add one

The enable/start split catches people out most. The systemctl manual is explicit that enabling "does not have the effect of also starting any of the units being enabled". If a service works after start but is gone after a reboot, you forgot enable. If it is enabled but not running right now, you forgot start.

How to read systemctl status output

systemctl status cron

Example output from Ubuntu 22.04 (systemd 249):

● cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2026-10-26 13:27:40 EET; 12s ago
       Docs: man:cron(8)
   Main PID: 187 (cron)
      Tasks: 1 (limit: 38222)
     Memory: 436.0K
     CGroup: /system.slice/cron.service
             └─187 /usr/sbin/cron -f -P

Oct 26 13:27:40 devbox systemd[1]: Started Regular background program processing daemon.
Oct 26 13:27:40 devbox cron[187]: (CRON) INFO (pidfile fd = 3)
  • Loaded shows the unit file path and whether it is enabled (starts at boot). vendor preset is the distribution's default for that unit.
  • Active is the current state: active (running), inactive (dead) (stopped), failed (it crashed or exited with an error), or activating (still starting).
  • Main PID is the process you would see in ps aux.
  • The lines at the bottom are the most recent journal entries for the unit. When a service is failed, the reason is almost always here.

Long lines are truncated and the output opens in a pager. Add --no-pager -l to print everything straight to the terminal.

How to check if a service is running in a script

status is meant for people. For scripts, use the is- commands, which print one word and set the exit code:

systemctl is-active cron      # prints: active    exit code 0
systemctl is-enabled cron     # prints: enabled   exit code 0
systemctl is-failed cron      # exit code 0 only if the unit has failed

For example, systemctl is-active --quiet nginx || sudo systemctl start nginx starts nginx only if it isn't running. systemctl status also has meaningful exit codes, taken from the LSB standard:

Exit codeMeaning in systemd
0Unit is active
1Unit not failed (used by is-failed)
3Unit is not active
4No such unit

On the test machine above, systemctl status nosuchthing printed Unit nosuchthing.service could not be found. and exited with 4, and systemctl is-active nosuchthing printed inactive and exited with 3. Note that last one: is-active does not distinguish "stopped" from "doesn't exist", so check the name if a script insists a service is down.

How to list services

systemctl list-units --type=service --state=running
systemctl list-units --type=service --all
systemctl --failed
systemctl list-unit-files --type=service

Example output of the first command, shortened:

  UNIT                        LOAD   ACTIVE SUB     DESCRIPTION
  cron.service                loaded active running Regular background program processing daemon
  dbus.service                loaded active running D-Bus System Message Bus
  rsyslog.service             loaded active running System Logging Service

list-units shows units that are loaded in memory: by default only those that are active, have pending jobs or have failed. --all adds inactive ones. list-unit-files shows every installed unit file and its enablement state, whether loaded or not, which is where you see the states below.

StateMeaning
enabledStarts at boot (or when its target is reached)
disabledCould be enabled (it has an [Install] section) but isn't
staticHas no [Install] section, so it can't be enabled; something else starts it
maskedLinked to /dev/null; every attempt to start it fails
generatedCreated at boot by a generator, for example from /etc/fstab

How to see a service's logs

systemd sends service output to the journal. Read it with journalctl:

journalctl -u nginx -n 50          # last 50 lines
journalctl -u nginx -f             # follow new lines live (Ctrl+C to stop)
journalctl -u nginx -b             # only since the current boot
journalctl -u nginx --since "1 hour ago"
journalctl -p err -b               # all errors from this boot, every unit

Without -n, journalctl shows the whole history in a pager, oldest first; add -e to start at the end. If you see no output for a system service as a normal user, your account is not in the systemd-journal or adm group: add sudo.

How to see and change a service's unit file

systemctl cat cron

This prints the unit file and any drop-in overrides, each preceded by a comment with its path (here, # /lib/systemd/system/cron.service). Files under /lib/systemd/system/ or /usr/lib/systemd/system/ belong to the package that installed them, so don't edit them in place. systemd reads /etc/systemd/system/ first, and anything there takes precedence. The easy way to put an override there is:

sudo systemctl edit nginx

That opens your editor on a drop-in file (override.conf) where you put only the settings you want to change, for example a [Service] section with Restart=always. systemctl reloads the configuration when you save; restart the service so the running process picks up the change. If you create or edit unit files by hand instead, run sudo systemctl daemon-reload yourself. Otherwise systemctl warns: Warning: The unit file, source configuration file or drop-ins of nginx.service changed on disk. Run 'systemctl daemon-reload' to reload units.

User services: systemctl --user

Everything above talks to the system-wide service manager. Add --user to manage services that run as your own account, with unit files in ~/.config/systemd/user/, and no sudo: systemctl --user status, systemctl --user enable --now myapp. Logs for those are in journalctl --user -u myapp.

If systemctl itself fails

  • Failed to start nginx.service: Interactive authentication required. You ran a state-changing command without sudo.
  • Unit nginx.service could not be found. or Failed to get unit file state for nginx.service: No such file or directory: the name is wrong or the package isn't installed. Find the real name with systemctl list-unit-files | grep -i nginx.
  • System has not been booted with systemd as init system (PID 1). Can't operate. PID 1 is a different init, which is common inside Docker containers and in WSL distributions other than the current default Ubuntu. Check with ps -p 1 -o comm=: it prints systemd when systemd is running. In WSL 2, add [boot] and systemd=true on two lines to /etc/wsl.conf, then run wsl --shutdown in PowerShell and reopen the distribution (see the WSL install guide for the basics).
  • The service starts and immediately becomes failed: read journalctl -u nginx -n 50. Once you've fixed the cause, sudo systemctl reset-failed nginx clears the failed state and the restart rate limit. To check what the main process is doing while it runs, the ps aux guide explains the columns.

Frequently asked questions

What is the difference between systemctl enable and systemctl start?
start runs the service now, for this boot only. enable creates the symlinks that make the service start automatically at boot, but does not start it now. Use systemctl enable --now name to do both in one command.
Do I need to type .service after the unit name?
No. If you leave the suffix off, systemctl assumes .service for most commands, so systemctl restart nginx and systemctl restart nginx.service are the same. Other unit types such as timers, sockets and targets need their suffix, for example systemctl list-timers or systemctl status apt-daily.timer.
What does 'Interactive authentication required' mean?
You ran a command that changes system state, such as start, stop or enable, as a normal user without a way to enter a password. Run it again with sudo. Read-only commands like status, is-active and list-units work without sudo.
What does a static service mean in systemctl?
static means the unit file has no [Install] section, so it cannot be enabled or disabled on its own. It is started by something else, such as another service, a timer or a socket. systemctl is-enabled reports static with exit code 0, so scripts treat it as fine.

Sources