Performing basic functions in the command-line can be challenging if you're used to the GUI-based workflow of Windows or Linux desktops. A particular hurdle is working out how to get a list of running services when you cannot lean on hotkeys such as Ctrl + Shift + Esc or Ctrl + Alt + Del.

Listing services in Linux is a key part of server management. It allows you to check whether necessary services are running correctly or whether something is running that shouldn't. Fortunately, there are several ways to list services in Linux, though the commands can vary depending on the distribution. In this blog, we'll cover listing services on the most popular ones: Ubuntu, Debian, CentOS, and Fedora.

How to list services in Linux

Linux has multiple easy ways to list services, with the most obvious being the service command. This command should work on all distros that support System V init scripts.

service --status-all

This will list all services, whether they're running or not, with a + next to the ones that are. You can also filter out services that are running using grep:

service --status-all | grep '\[ + \]'

And the ones that aren't by changing that + to a -:

service --status-all | grep '\[ - \]'

You can find the status of a particular service by typing service {service name} status. For example, service ssh status will return:

ssh.service - OpenBSD Secure Shell server     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)     Active: active (running) since Mon 2022-12-19 08:21:39 UTC; 24h ago

Listing services with systemctl

Many will prefer to use the systemctl command over service because it shows more information and outputs in a tabular format. It also works on all of the Linux distributions mentioned. The list-units option will list all services, regardless of whether they are active or not.

systemctl list-units --type=service

systemctl list-units --type=service --all, meanwhile, shows services that are active or have failed.

You can filter those to only active service by using:

systemctl list-units -a --state=active

And inactive units with:

systemctl list-units -a --state=inactive

Want to list only running services? Use this instead:

systemctl list-units --type=service --state=running

If you want to see the services that have failed (for troubleshooting purposes), you can use the --state option:

systemctl list-units --state=failed