System services are the processes or system programs known as ‘daemons’ that continuously run in the background. These services wait for client requests and are responsible for how the system works and how it communicates with other programs. When working in a Linux environment, including Ubuntu, you can easily manage all system services (start, stop, restart, enable at system boot, etc.) through a service manager. Most of the modern Linux distributions, such as Ubuntu, now use a process manager known as ‘systemd’. The systemd is a service manager in the Ubuntu system and used to replace the ‘init’ process. The systemd services manager is controlled by the primary command-line tool ‘systemctl’ command.

We will show you the various techniques in this tutorial related to listing or viewing all services in the Ubuntu 20.04 system.

How to list all services in Ubuntu?

Various services are running in the background of your Ubuntu Linux distribution. While working as a system administrator, you must know how to view all services, including system services such as (login, process management, syslog, cron jobs). You must have the knowledge to view all network services (remote login, web hosting, file transfer, DNS and DHCP, etc.) using the systemctl command and other ways you can control or manage all Linux services. We will also discuss this in this article.

List all services using the systemctl command

When the systemctl command is used without any arguments, in this case, it displays the list of loaded systemd units, including services either these are active or not.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-1.png" data-lazy- height="631" src="data:image/svg xml,” width=”912″>

The following command will also display all services unit files:

$ systemctl list-units –all –type=service –no-pager

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-2.png" data-lazy- height="673" src="data:image/svg xml,” width=”913″>

In the output, the details about UNIT, LOAD, ACTIVE, SUB, and service Description displays in the form of columns as follows:

  • UNIT This column shows the corresponding details about the systemd unit name.
  • LOAD The column displays the information about the unit, either currently loaded in the memory or not.
  • Active This column shows whether the systemd unit is active or not.
  • SUB This column shows the running state of the systemd unit.
  • DESCRIPTION This column displays the short details about the unit.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-3.png" data-lazy- height="186" src="data:image/svg xml,” width=”916″>

How to list systemd unit files?

The below-mentioned will show the all available systemd unit files rather than their type and running status info:

$ systemctl list-unit-files –no-pager

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-4.png" data-lazy- height="668" src="data:image/svg xml,” width=”913″>

Use the grep command in case you are searching for a specific unit file. For example, the below command will search for an apache2 unit file:

If you want to search for a specific unit file, you can also perform this action using the grep command.

$ systemctl list-unit-files –no-pager | grep service-name

For example, we want to search an apache2 service unit file by using the grep command as follows:

$ systemctl list-unit-files –no-pager | grep apache2

The above command will retrieve all unit files related to the apache2 service that you can see in the following screenshot:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-5.png" data-lazy- height="97" src="data:image/svg xml,” width=”890″>

How to list systemd service unit files using states?

The following systemctl command will show you the information about all enabled systemd unit files on Ubuntu 20.04 system:

$ systemctl list-unit-files | grep enabled

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-6.png" data-lazy- height="627" src="data:image/svg xml,” width=”912″>

To display all disabled systemd unit files, run the below-mentioned command:

$ systemctl list-unit-files | grep disabled

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-7.png" data-lazy- height="629" src="data:image/svg xml,” width=”912″>

The services that are enabled on your system automatically start on system reboot.

List all active or running services

Using the ‘systemctl’ command, you can filter active or running services from the all services list as follows:

$ systemctl list-units –all –type=service –no-pager | grep running

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-8.png" data-lazy- height="629" src="data:image/svg xml,” width=”910″>

Or

$ systemctl –type=service –state=running

List all excited services

By running the below-given command, you can easily list all services with the excited state:

$ systemctl list-units –all –type=service –no-pager | grep exited

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-9.png" data-lazy- height="54" src="data:image/svg xml,” width=”912″>

List all stopped or dead services

With the help of the following command, you can easily list all disabled services on the terminal window:

$ systemctl list-units –all –type=service –no-pager | grep dead

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-10.png" data-lazy- height="522" src="data:image/svg xml,” width=”914″>

Managing systemd services using systemctl

The systemctl is the most commonly used command to manage the systemd unit files and services in Ubuntu 20.04 distribution. Users can enable, disable, start and stop services using the following commands respectively.

$ sudo systemctl enable service-name


$ sudo systemctl disable service_name


$ sudo systemctl start service_name


$ sudo systemctl disable service-name

Using the above commands, you can control each service state based on your requirements.

View service status using systemctl command

To view the detailed information about a particular service, use the below-mentioned command:

$ sudo systemctl status service-name

For example, we want to check the complete status of the ‘ssh’ service. In this case, by running the following command, you can display the complete status of the ssh service as follows:

$ sudo systemctl status ssh

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-11.png" data-lazy- height="422" src="data:image/svg xml,” width=”910″>

More commands to list services in Ubuntu

Use of pstree command

Using the ‘pstree’ command, you can list all running Ubuntu services in the form of the tree structure as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-12.png" data-lazy- height="665" src="data:image/svg xml,” width=”914″>

List firewall services

By running the following command, the user can easily list firewall services and ports:

$ sudo firewall-cmd –list-services

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-13.png" data-lazy- height="84" src="data:image/svg xml,” width=”916″>

$ sudo firewall-cmd –list-ports

List top control groups with resource utilization

The ‘systemd-cgtop’ command is used to display the top control groups by their resource utilization as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-14.png" data-lazy- height="668" src="data:image/svg xml,” width=”914″>

The previous Ubuntu distributions use the ‘service’ command to list all system services as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-15.png" data-lazy- height="615" src="data:image/svg xml,” width=”912″>

You can also view all services by directly listing the /etc/init.d directory in older Ubuntu systems as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-can-I-see-all-services-in-Ubuntu-16.png" data-lazy- height="373" src="data:image/svg xml,” width=”910″>

Conclusion

We learned how to list all services in Ubuntu 20.04 system using the systemctl command. We have also experienced various commands that are also helpful in listing all Ubuntu services. Most of the commands, like the service command, are obsolete now. In the latest Ubuntu distribution, system administrators use ‘systemctl’ to get the details about all systemd services. The systemctl command also offers advanced features and is quite more useful as compared to the other service listing commands.

About the author

<img alt="" data-lazy-src="https://secure.gravatar.com/avatar/49ac9cf0c583f1d7e06205a87f549d76?s=112&r=g" data-lazy- height="112" src="data:image/svg xml,” width=”112″>

Samreena Aslam

Samreena Aslam holds a master’s degree in Software Engineering. Currently, she’s working as a Freelancer & Technical writer. She’s a Linux enthusiast and has written various articles on Computer programming, different Linux flavors including Ubuntu, Debian, CentOS, and Mint.