Linux Commands

Listing Linux Services With Systemctl

Listing Linux Services With Systemctl

A variety of services run continuously on a Linux background, such as network and system services. Services running on Linux are also known as daemons, which refers to a group of processes working on the back-end.

Services can be managed and listed through different methods and tools. The Systemd is a software suite of tools with the ability to manage Linux systems adopted by Linux distribution as a drop-in replacement of the init process.

All system tasks can be controlled through Systemd. The process can be started or ended using this tool, and all enabled and disabled services information can also be listed with Systemd.

List Services Using Systemctl in Linux

Systemctl is a utility with the responsibility to manage and control the systemd system. The systemctl command can be used to list all services in Linux.

We will now show you how systemctl works.

List All Services

To get a list of all the services on the system, whether they are loaded or inactive, issue the following systemctl command in the terminal:

$ systemctl list-units --type=service --all

All services in your system will appear on the screen, as you can see in the output shown in the image above.

List Loaded Services

The following command will list every loaded service that is running, active, or failed:

$ systemctl list-units --type=service

Running Services

In many cases, it can be difficult to distinguish the running services from all the other services. Run the following command to obtain a quick response that shows the loaded and running services in the system:

$ systemctl list-units --type=service --state=running

Enabled Services

Enter the following command to check the enabled services in the system:

$ systemctl list-unit-files --state=enabled

Disabled Services

Disabled services will not start up or activate automatically. To enable a desired/required service, select the service from the disabled category. The following command is used to obtain a list of the disabled services in the system:

$ systemctl list-unit-files --state=disabled

Check Service Status

The “cup” command is used to obtain more information about the status of a service. Cup is a modular printing system through which the computer acts as a print server and displays information. Use the cups command to obtain more information about the enabled/disabled services in the system:

$ systemctl status cups.service

Where are systemctl service files

Systemd configuration files are stored in specific directories. There are System unit directories and User unit directories.

You can find the location of the System Unit and User Unit directories using the pkg-config systemd command.

Run the following commands to find the directories on your system:

$ pkg-config systemd --variable=systemdsystemunitdir

$ pkg-config systemd --variable=systemduserunitdir

You can browse to these directories and see the systemd unit files.

Conclusion

This article showed you how to use systemctl commands to list services in Linux, including multiple options for viewing the services. With the correct knowledge, it is easy to pick the required command.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.