List services
service
The service --status-all command will list all services on your Ubuntu Server (both running services and not running services):
service --status-all
Using the grep command, we can filter the output to show only the running services:
service --status-all | grep '\[ + \]'
To list Ubuntu services that are not running, type:
service --status-all | grep '\[ - \]'
The service command can be used to list services in all Ubuntu releases, including Ubuntu 17, 16.04, and 14.04.
systemctl
To list all running services on Ubuntu, Type:
systemctl list-units
Count
running services
service --status-all | grep -c '\[ + \]'
not running services
service --status-all | grep -c '\[ - \]'
all services
service --status-all | grep -c ''
Although service is still working on ubuntu 22, it is recommended to use systemctl for list running services as follows:
sudo systemctl list-units --state running