On most current Linux distributions, you can list running services with systemctl. This article shows the commands, explains how to read their output, and covers how to find the network ports that services listen on.
Short answer
On a systemd-based system, run:
systemctl list-units --type=service --state=running
This lists the services that are running right now. It does not show every process on the machine, which is covered later in this article.
Reading the output
The output has five columns:
- UNIT is the service name, such as
cron.service. - LOAD shows whether systemd has loaded the service’s configuration.
- ACTIVE is the broad state, such as
active. - SUB is the detailed state, such as
running. - DESCRIPTION is a short label for the service.
If you pipe the output into another command or a script, add --no-pager so the output is not paged.
List every loaded service, including stopped ones
To see services that systemd has loaded but that are not running, add --all:
systemctl list-units --type=service --all
This is useful when you are checking whether a service exists and is simply stopped.
See which services start at boot
Running now and starting at boot are different things. To see whether each service is enabled, disabled, or static:
systemctl list-unit-files --type=service
A service that is running but disabled will not start again after a reboot. To show only enabled services, add --state=enabled.
Check a single service
To see the state of one service, including when it started and its recent log lines:
systemctl status ssh
Replace ssh with the name you need. Unit names can differ between distributions. The SSH service is usually ssh on Debian and Ubuntu, and sshd on Red Hat-based systems.
Older init scripts on Debian and Ubuntu
On Debian and Ubuntu, service --status-all lists the SysV-style init scripts it knows about and marks running ones with [ + ]. Use it when you are not sure of a service name, then confirm the state with systemctl.
Find services listening on the network
To see which programs accept network connections:
sudo ss -tulpn
The -t and -u flags show TCP and UDP sockets, -l shows only listening sockets, -p shows the owning process, and -n shows numeric addresses and ports. A listening address of 0.0.0.0 or [::] means the program accepts connections on all interfaces, unless a firewall or the program’s own settings limit access.
Processes are not always services
ps -ef and ps aux list every process, including user programs and kernel threads. Use them when you need to see what is running right now, not only what systemd manages.
Common mistakes
- Using the wrong unit name. Check the exact name with
systemctl list-unitsbefore you run a command against it. - Confusing running with enabled. A service can be running now and still be disabled at boot.
- Expecting netstat. Many current distributions do not install net-tools by default, so use
ssinstead.
Next steps
Once you know the service name, you can restart it safely. The guide on how to restart network services in Linux explains which command to use for each network manager. For a broader set of tools, see what are 10 common network commands.