When we administer Linux Operating Systems we must take into account that there are a series of parameters that are essential for the proper functioning of the system in general and one of these are the Linux services..
Basically a service in Linux runs in the background and its task is to give a specific function in the system. The default services (mostly) start automatically during system boot and will be active and running in the background in order to respond to requests generated by applications or the user.
In Linux Operating Systems, services are managed through the startup system, which is in charge of starting, stopping, and managing these services in the background, normally the startup system is SysVinit, systemd, Upstart, or some others, taking into account account the distribution used..
Systemctl is a command in Linux with which it is possible to control the systemd startup system, thanks to this command as users we will be able to manage background services, system units and system sockets creating an availability environment much more complete. Systemctl gives us the opportunity to start, stop, restart and verify the status of background services as well as disable that service from starting automatically or perform extra tasks such as:
Systemctl Tasks
- Check the status of system drives.
- Validate file system mounts.
- Manage network devices, storage devices and more.
TechnoWikis will explain how to use systemctl to list the services in Linux and thus manage them in a much more complete way.
To stay up to date, remember to subscribe to our YouTube channel!
SUBSCRIBE ON YOUTUBE
How to list Linux services with Systemctl
Step 1
We open the terminal and list the desired entries to check Systemd:
pstree | head -#
Step 2
There we have validated the process tree with the pstree command and we noticed that Systemd is used.
Step 3
We validate the running services:
systemctl --type=service --state=running
Step 4
You can use the directional arrows to see more content:
step 5
We found details like:
- Unit: is the name of the service or daemon.
- Load: indicates the load status of the service or daemon, its options are loaded, not-found, bad-setting, error, or masked.
- Active: indicates the current general status of the service or daemon, the options are active, reloading, inactive, failed, activating, or deactivating.
- SUB: is the substatus of the service or daemon, there we can see results such as dead, exited, failed, inactive, or running.
- Description: It is a brief description of the service.
step 6
You can see the status of a specific process:
systemctl --type=service --state=running | grep(name)
step 7
We validate failed services:
systemctl --type=service --state=failed
step 8
It is possible to enter two states simultaneously:
systemctl --type=service --state=failed,exited
step 9
We use the directional arrows to see the other results:
step 10
To list active file units we execute the command. Allie we found details such as the name of the unit, its current state and other values.
systemctl list-unit-files --state=enabled
step 11
We remove the “—state” parameter for general results:
systemctl list-unit-files
step 12
You can use various parameter options if necessary:
systemctl list-unit-files --state=enabled,failed
step 13
To validate the disabled file units we execute:
systemctl list-unit-files --state=disabled,failed
step 14
To see a service in detail we execute:
systemctl status (service)
step 15
There we see values like:
- The process ID of the instance
- How much CPU time has been used
- Concurrent instances of this service and more
Thanks to Systemctl we will be able to take complete control over the services in Linux and thus manage them efficiently..