In this guide, we will explore how to effectively list all services on your Linux machine, taking into account your specific system manager.
As a system administrator, you likely encounter a multitude of services on a daily basis.
Linux utilizes services for various purposes, such as initiating an SSH server or executing specific tasks at scheduled times.
Regardless of whether you are working with a Debian-based distribution or a RedHat-based one, the process of querying services remains quite similar.
However, depending on the distribution and the initialization system employed (init or systemd), you may need to employ different commands.
Step - Determine the Service Manager
The first step before determining how to list the services running on a given Linux system is to determine the system manager available in the system.
The easiest method to determine the system manager using the
ps command as:
ps -p 1 -o comm=
The example output below shows a system using the
If the output is “systemd“, it means that you are currently using systemd. However, if you see “init“, it means that you are using SysVinit.
Listing Services Using Systemd
If you are using
systemd as your system manager, you can list the services available in the system using the
systemctl command followed by the
list-units option as shown:
systemctl list-units --type=service
The command should return all the active services on the system.
To list all services, meaning active and inactive, you have to use the “systemctl list-units” command followed by the “–all” option.
systemctl list-units --type=service --all
List Services By State
In some cases, you may only be interested in services that have failed. For that, you can specify the state that you are looking for as an option of the systemctl command.
systemctl list-units --state=<state> systemctl list-units --state=<state1>,<state2>
For example, to list failed services:
systemctl list-units --state=failed
List All Services Using List Unit Files
To list all service files available, you have to use the “systemctl” command followed by “list-unit-files”. Optionally, you can specify the type by using the “–type=service” option.
systemctl list-unit-files --type=service
List Services Using Service SysV Init
The easiest way to list services on Linux, on a SystemV init system, is to use the “service” command followed by “–status-all” option. This way, you will be presented with a complete list of services on your system.
[ - ] cron [ ? ] hwclock.sh [ ? ] kmod [ ? ] networking [ + ] postgresql [ - ] procps [ - ] rsyslog [ - ] sudo [ - ] sysstat [ + ] udev
- + : means that the service is running;
- – : means that the service is not running at all;
- ? : means that Ubuntu was not able to tell if the service is running or not.
List SysVinit Services in Directories
Another way of listing the current list of services is to use the “ls” command on the folders containing all scripts on a Linux system, namely “/etc/init.d”.
ls -l /etc/init.d/*
-rwxr-xr-x 1 root root 3059 Feb 23 2021 /etc/init.d/cron -rwxr-xr-x 1 root root 1748 Jan 20 2022 /etc/init.d/hwclock.sh -rwxr-xr-x 1 root root 2044 Jan 8 2021 /etc/init.d/kmod -rwxr-xr-x 1 root root 4486 Sep 21 2020 /etc/init.d/networking -rwxr-xr-x 1 root root 1490 Nov 15 2019 /etc/init.d/postgresql -rwxr-xr-x 1 root root 924 Apr 6 2021 /etc/init.d/procps -rwxr-xr-x 1 root root 2864 May 21 2022 /etc/init.d/rsyslog -rwxr-xr-x 1 root root 1030 Feb 27 2021 /etc/init.d/sudo -rwxr-xr-x 1 root root 1581 Feb 3 2021 /etc/init.d/sysstat -rwxr-xr-x 1 root root 6871 Aug 7 2022 /etc/init.d/udev
In this tutorial, you learnt how you can easily list services on a Linux system whether you are using systemd or SysVinit ones.