If you are the system administrator, you can see all the services like process manager, login, syslog, and so on running in the background on your device.
These services help with how the system works and connects to other programs. And you can also list all these services on Ubuntu.
Here at Ibmi Media, we shall look into how to list all services by using the systemctl command on Ubuntu 20.04.
It's syntax is given below:
$ systemctl [options] [command]
To list all the services, run:
$ systemctl --no-pager
1. How to list all unit files ?
To do this, Run the following command:
$ systemctl list-units --all --type=service --no-pager
2. How to list systemd unit files ?
To do this, Run:
$ systemctl list-unit-files --no-pager
3. How to combine grep command to search for specific unit file ?
The syntax:
$ systemctl list-unit-files --no-pager | grep service_name
For example, We want to search for “session”:
$ systemctl list-unit-files --no-pager | grep session
4. How to list systemd service unit files by state ?
We will combine the grep command to do this. For example, We will list systemd service unit files are in the enabled state:
$ systemctl list-unit-files | grep enabled
Also, you may want to list systemd service unit files in the disabled state with the below command:
$ systemctl list-unit-files | grep disabled
5. How to list services using pstree command ?
The command to do so is given below:
$ pstree
6. How to List the groups that use the most resources ?
Run the following command to do so:
$ systemd-cgtop
This article covers how to list all services by using the systemctl command on Ubuntu 20.04. In fact, systemctl is a command-line utility that is used for controlling systemd and managing services, which is part of systemd.
The syntax is the rule and format of how the systemctl command can be used.
These syntax options can be reordered, but a straight format must be followed:
systemctl [OPTIONS.] {COMMAND}