For a clearer understanding of this article, we will have to explain a few terms briefly. systemd, daemons, socket, and services.
We have talked about the systemd as the parent process where other processes are generated, and it has a process ID of 1. What is more to it?. The systemd is a program that activates system resources, server daemons, and other processes both at boot time and running time. In most Linux distro, The process ID 1 is the systemd, the new init system, an improvement from the previous init system, which is the system V.
Then what are daemons?. Daemons are processes that run at the background perform several tasks. They are started at boot time by the system and can continue to run until they are manually stopped. They run on no terminal. The letter d generally represents daemons at the end of their names. Daemons listen to connections through sockets which might be created by them or by another process such as the systemd.
Services are one or more daemons. It is a program that responds to request from other programs. It is hard for anyone out day to break it down for newbies. You will get to understand the difference when you get used to the Linux environment. Windows don’t see both words as separate words. In windows, daemons are services.
In this article, you will learn how to list system daemons and network services started by the systemd services
WHAT IS systemctl
We will be using systemctl to manage systemd units. The systemctl is just a command or a tool for managing these units. There are various units available in Linux, but I will be listing some common ones. Meanwhile, you can view all available system unit types by entering systemctl –l on the command line.
There are lots of units. This is a device unit, but you can keep pressing the enter key on your keyboard to see all units in the system
The most common units are as follows;
Service units: These are system units used for accessing frequently used daemons. They end with the .service extension.
Socket units: The socket units are used to delay services during boot and start less frequently used services when needed. They have .socket extension
Path units: The path units are used to delay the activation of service until a change has occurred on a specific file system. They have .path extension
You can as well check the status of any unit to know its state by entering;
systemctl status NameOfUnits
Our chronyd service is active and running. A service can be either active (running), active(exited), active (waiting), inactive, loaded, enabled, disabled and static.
HOW TO LIST THE UNIT FILES
To list any unit type in the system, you use the systemctl command. In this section, we will demonstrate how to obtain status information about a service.
HOW TO QUERY THE STATE OF ALL AVAILABLE UNITS
You can verify the status of all units in the system to check their state in the system startup by entering the systemctl on the command line
These are the status of all available units in the system. you can use the arrow key to scroll down to see more of the units
HOW TO QUERY THE STATE OF A SINGLE UNIT
Querying the state of all the units could be confusing while trying to get the information of a single unit. You can as well query just the state of a single unit by typing systemctl –type service on the command line.
This is information about the service unit. You can choose to query the state of any unit and replace the service to any unit of your choice like the socket unit. The description section shows the function of each unit. You can as well read through that to know the function of the units
HOW TO DETERMINE IF A UNIT IS ACTIVE AT BOOT TIME
The above commands demonstrated can be used to determine if a unit is active, failed, or enabled at boot time. However, you can as well use the following alternate method to know that as well.
Our chronyd service is active and enabled
HOW TO LIST THE ACTIVE STATE OF ALL LOADED UNITS
You can list all available units in the system by appending –all after your command. I will demonstrate below. The –all option will list both the inactive and active units. Without the –all option will only list active units
You can also do the same with other units in the system, such as socket by
replacing the service unit to any unit of your choice.
Without the –all option, it will list only the active services ignoring the inactive ones
HOW TO VIEW ONLY FAILED SERVICES
You can as well choose to view only failed services as shown below
This indicates only failed units. Please note that “fail” is different from “failed.” When you go to your command line, and use fail instead of failed, it will display all active and failed units as seen below
HOW TO THE VIEW ENABLED AND DISABLED SETTINGS OF ALL SETTINGS
You can as well view all unit types if they are disabled or enabled by using the following command
CONCLUSION
Now you can list system daemons and network services to determine their status. Please remember to used your tab completion key to help you complete the uniqueness of what you want to type. I believe it is very important while using the systemctl to view your network services.
Note that systemctl might ellipse unit names, process tree entries and unit description except when run with the –l option at the end of your command
Also, note that when a unit type is typed on the command line without the unit extension, the system assumes it to be a service unit
Syntax as seen below;
[systemctl status] [chronyd] [-l]
REFERENCES
RedHat System Administration I Course
Systemctl man page