UNIX operating systems, such as Linux, are made up of numerous services that are intended to allow each role, application and process of the system to be fulfilled based on the criteria for which they were established, thus, for example, The httpd service is responsible for managing everything related to Apache, optimizing access to web services. If a service failed, the associated process would simply generate errors..
If your role is to be an administrator or support staff, it is essential to know in detail what services are present on the server and therefore know in real time the status of them. In this case we will learn to manage the services in CentOS 8 and it is important to clarify that there the services are managed through the "systemctl" command, which allows us to start, stop or restart the service .
1. How to list current services in CentOS 8
Step 1
For CentOS 8 we can use the “systemctl†command to list and manage the services, so that to list all the services present in CentOS 8 we will execute the following:
systemctl
Step 2
As a result we will see the following values:
- LOAD (Service activity time)
- ACTIVE SUB (Activity Function)
- DESCRIPTOR (directory where the service is)
Step 3
We can use the -more parameter to list the services in more detail:
systemctl | more
Step 4
In order not to get lost in this sea of ​​data, we can use “grep†to filter by the desired service, for example:
systemctl | grep httpd
Step 5
There we find details like:
We can list all services with your current state only by running the following:
systemctl list-unit-files
Step 6
It will be possible to visualize the processes associated with a particular service (cgroup), with the systemd-cgtop command.
This command is similar to the top command because it lists the running processes based on the function of your service, we execute the following:
systemd-cgtop
This will list the following:
- Tasks linked to the service
- Percentage of CPU, memory and input and output data used
2 . How to list SysV services in CentOS 8
SysV is a system of execution levels "SysV init" which are responsible for managing which init programs launch or stop just when the execution level is carried out.
We can list these services in CentOS 8 by running:
chkconfig –list
3. How to view the status of a service in CentOS 8
This is a key point to determine if the service is working as expected and with it all the linked processes, to check the status of any service in CentOS 8 we will use systemd as follows:
systemctl status httpd.service
There we find specific details of the selected service such as:
Loaded
Indicates the directory in which the service is hosted
Active
There we determine whether the service is active (active) or disabled (disable)
Docs
Route the service manual
Main PID
Refers to the PID associated with the selected service
Status
Indicates the current status of the service by attaching additional information
Task
Deploy the tasks related to that service
Memory:
Displays the amount of memory used by the service
CGroup
They are the groups associated to the service deployment
4. How to stop a service in CentOS 8
Step 1
If for any management task we must stop a service in CentOS 8, the syntax to be used will be the following:
systemctl stop “serviceâ€
This requires entering the administrator password:
Step 2
We can verify that the service has been stopped by running systemctl status:
Step 3
Start a service in CentOS 8
Now, to start the service again we will use the following syntax:
systemctl start “serviceâ€
Enter the administrator password and then verify that the service has started:
Restart a service in CentOS 8
Another option is to restart a service without having to stop it, for this we will use the following syntax:
systemctl restart “serviceâ€
Step 4
Alternatively it will be possible to only load the configuration of the service without interrupting as such its execution, for this we will use the following:
systemctl reload “Serviceâ€
Step 5
As an end point, you can use the following lines to verify the status of a service in CentOS 8:
systemctl is-active httpd systemctl is-enabled httpd
Thus, thanks to TechnoWikis, you have learned simple methods to know the status of services in CentOS 8 and manage them in a much more global way according to the needs..