Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto
Linux

List running services on Linux and audit what should run

List running, enabled and failed services on Linux with systemctl, trace a process to its unit, check timers and sockets, and audit what should run.

CloudSat teamNovember 18, 20267 min read
Abstract illustration of a control board with rows of small lights, most steady, one blinking, one dark, wired to a central hub.
On this pageRunning, enabled and installed are different lists

Old guides split this question by distribution: one method for Ubuntu, another for Debian, a third for CentOS. That split is history. Ubuntu, Debian, AlmaLinux, Rocky Linux, Fedora, openSUSE and Arch all run systemd, so one set of systemctl commands answers it everywhere. Alpine and Gentoo use OpenRC instead; their commands are at the end.

Running, enabled and installed are different lists

Three questions hide behind "which services do I have?":

  • Running: active right now.
  • Enabled: set to start at boot, or when a socket, timer or another unit asks for it.
  • Installed: a unit file exists, whatever its state.

They drift apart all the time. A service can be enabled but dead after a crash, or running but not enabled because someone started it by hand and it will be gone after the next reboot.

systemctl list-units --type=service --state=running        # running now
systemctl list-units --type=service                        # loaded and active, including finished one-shots
systemctl list-units --type=service --all                  # inactive ones too
systemctl list-unit-files --type=service --state=enabled   # what starts at boot
systemctl --failed                                         # what crashed

Add --no-pager when you paste the output somewhere, and --plain --no-legend when a script needs to count lines.

list-unit-files shows a STATE column with more values than enabled and disabled. static means the unit has no install section and only starts when another unit needs it; you cannot enable it, and you do not need to. indirect units are enabled through another unit, generated ones are created at boot from files such as /etc/fstab, and masked units are blocked from starting at all.

Read the columns

Column Common values Meaning
LOAD loaded, not-found, masked whether systemd could read the unit file
ACTIVE active, inactive, failed, activating the high-level state
SUB running, exited, dead, auto-restart the detailed state

active (exited) is not an error. It marks a one-shot unit that ran a job and finished successfully, such as a firewall loader. auto-restart means the service died and systemd is about to try again, so look at its log before it fails for good.

Inspect one service

systemctl status nginx                     # state, main PID, memory, last log lines
systemctl is-active nginx; systemctl is-enabled nginx
systemctl cat nginx                        # the unit file plus every drop-in override
systemctl show nginx -p MainPID -p ActiveEnterTimestamp -p NRestarts
journalctl -u nginx -b --no-pager | tail -n 30
journalctl -u nginx --since "1 hour ago"

systemctl cat matters more than it looks: the effective configuration is the vendor unit plus any files in /etc/systemd/system/nginx.service.d/, and only cat shows them together. NRestarts counts how often systemd has restarted the service, a quick sign of a crash loop.

When a service keeps failing

A service that crashes several times in a few seconds hits systemd's start limit, and systemctl status reports "Start request repeated too quickly". Restarting again changes nothing until you find the cause. A reliable order of work:

  1. Read the last lines with journalctl -u myapp -n 50 --no-pager. The real error is usually just above systemd's own messages.
  2. Run the ExecStart command by hand as the service's user, for example sudo -u myapp /usr/bin/myapp --config /etc/myapp.yml, to see the error in your terminal.
  3. Fix the configuration. To change the unit itself, use sudo systemctl edit myapp, which writes an override file and reloads systemd for you; after editing unit files directly, run sudo systemctl daemon-reload.
  4. Clear the counter with sudo systemctl reset-failed myapp, then start it again.

Services that do not look like services

Sockets

With socket activation, systemd listens on the port and starts the service on the first connection. Ubuntu runs SSH this way by default, so ssh.service can be inactive while ssh.socket accepts logins. Check both lists:

systemctl list-sockets

Timers

Timers are systemd's replacement for cron jobs, and most distributions now ship their housekeeping as timers: package list refreshes, log rotation, SSD trimming, certificate renewal.

systemctl list-timers --all

User services

Each logged-in user can run a private systemd manager with its own units, which is how rootless Podman containers and some sync tools run. On systemd 248 or newer, root can list another user's units directly, as long as that user's manager is running (the user is logged in, or lingering is enabled with loginctl enable-linger):

systemctl --user list-units --type=service              # your own
sudo systemctl --user -M alice@ list-units --type=service

Docker containers are not systemd units at all. List them with docker ps.

Which unit owns this process?

When ps or top shows a process you do not recognize, ask systemd which unit started it:

systemctl status 2210          # works with a PID
ps -o pid,unit,cmd -p 2210     # the unit as a ps column
systemd-cgls --no-pager        # every unit with its processes, as a tree
systemd-cgtop                  # live CPU, memory and I/O per unit

A process that belongs to no service unit was started from a login session or by cron; systemd-cgls shows it under a session-N.scope or a user slice.

Audit what should be running

On a server, every enabled service is code that listens, logs or wakes up for no reason if you do not need it. A short audit once in a while keeps the list honest:

  1. List the enabled units with systemctl list-unit-files --type=service --state=enabled.
  2. For each one you cannot explain, read systemctl cat <unit> and find its package with dpkg -S on Debian and Ubuntu or rpm -qf on the RHEL family, given the path of the binary in ExecStart.
  3. Compare with the network: sudo ss -tlnp shows which processes listen on which TCP ports.
  4. Turn off what you do not need with sudo systemctl disable --now cups.service.
  5. Use sudo systemctl mask <unit> for something that must never start, even as a dependency; unmask reverses it.

Leave the plumbing alone: dbus, systemd-journald, systemd-logind, networking, time sync, cron and your SSH server. Two analysis commands help with the rest. systemd-analyze security nginx.service scores how much of the system a service can reach and lists sandboxing options to tighten, and systemd-analyze blame shows which units slow down the boot.

Compare two servers

Servers built from the same recipe drift apart over months. Save the enabled list on each machine and compare the files:

systemctl list-unit-files --type=service --state=enabled --no-legend \
  | awk '{print $1}' | sort > /root/enabled-$(hostname).txt
diff /root/enabled-web-01.txt /root/enabled-web-02.txt

Any line that appears on one side only is either a missing piece of the setup or something installed by hand that nobody wrote down. Both deserve a note in your documentation.

OpenRC on Alpine and Gentoo

rc-status                       # services in the current runlevel and their state
rc-status -a                    # every runlevel
rc-service nginx status         # one service
rc-update show default          # what starts at boot
rc-update add nginx default     # enable at boot
rc-update del nginx default     # disable

CloudSat's Alpine Linux image uses OpenRC, so these are the commands you need there. On Debian and Ubuntu, service --status-all still exists as a wrapper for old init scripts, marking each with [ + ] or [ - ], but systemctl is the authoritative source.

FAQ

What does "active (exited)" mean?

The unit is a one-shot job that ran and completed without error. Nothing is running, and nothing needs fixing. If you expected a long-running daemon instead, check Type= in systemctl cat.

Why does a disabled service still start?

Something else pulls it in: a socket, a timer, a path unit or another service that declares it as a dependency. systemctl list-dependencies --reverse <unit> shows who wants it. Masking stops it for good.

How do I see what failed during the last boot?

systemctl --failed covers the current boot, and journalctl -b -p err lists every error logged since startup. For the boot before that, use journalctl -b -1 -p err, which needs a persistent journal (the /var/log/journal directory must exist).

Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.