Many times we may need to list all services in our Linux/Ubuntu system. systemd is the most common tool found in almost all Linux distributions to manage services. systemctl is a command utility that allows us to control systemd in turn. We will look at how to list all services using systemctl command. It is a very easy to use utility with many useful options.
How To List All Services in Systemctl
We will look at different use cases of systemctl to list all services.
Here is the command to list all services using systemctl. It will list all systemd units that are loaded whether they are services or not. This will include mounted file system elements as well.
$ sudo systemctl
If you only want to list all services, use the –type option. Please note, systemctl list-units below will also list all system units
# systemctl list-units --type=service OR # systemctl --type=service
Also read : How to Setup FTP Server in Ubuntu
List all active services
If you want to list all active services, use the –state option along with –type option
# systemctl list-units --type=service --state=active OR # systemctl --type=service --state=active
Also read : How to Redirect 403 to 404 in NGINX
List all running services
If you want to list all running services, use the following commands. We specify the type to be service and state to be running.
# systemctl list-units --type=service --state=running OR # systemctl --type=service --state=running
Also read : How to Configure X-Frame-Options in Apache
List All services including inactive ones
Use the following command to list all services including inactive ones. We use the –all option for this purpose.
# systemctl list-units --type=service --all
Also read : How to Install Erlang in Ubuntu
List all enabled services
You can list all enabled services, whether they are running or not using the following command. It will list services that run at startup. systemctl list-unit-files will list system file units.
# systemctl list-unit-files --state=enabled
Similarly, you can list all disabled services using the following command. These services will not run on startup.
# systemctl list-unit-files --state=disabled
Also read : How to Change User Password in Linux
Check status of service
If you want to check the status of a specific service such as apache2 then use the systemctl status command
$ sudo systemctl status apache2