+5 votes
298 views
How to activate, stop, restart and view CentOS 8 services

in Linux / Unix by (551k points)
reopened | 298 views

1 Answer

+3 votes
Best answer

1. How to list current services in CentOS 8
2 . How to list SysV services in CentOS 8
3. How to view the status of a service in CentOS 8
4. How to stop a service in CentOS 8

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:
  • UNIT (service name)
  • LOAD (Service activity time)
  • ACTIVE SUB (Activity Function)
  • DESCRIPTOR (directory where the service is)
image
Step 3

We can use the -more parameter to list the services in more detail:
 systemctl | more 
image
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 
image
Step 5

There we find details like:
  • Associated Service
  • Actual state
  • Description
We can list all services with your current state only by running the following:
 systemctl list-unit-files 
image
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:
  • Service Control Group
  • Tasks linked to the service
  • Percentage of CPU, memory and input and output data used
image

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 
image

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 
image

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: image
Step 2

We can verify that the service has been stopped by running systemctl status: image
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: image
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” 
image
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” 
image
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 
image

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..


by (3.5m points)
edited

Related questions

+5 votes
1 answer
asked Sep 22, 2019 in Linux / Unix by backtothefuture (551k points) | 264 views
+5 votes
1 answer
asked Oct 26, 2019 in Linux / Unix by backtothefuture (551k points) | 1.8k views
+3 votes
1 answer
asked Nov 16, 2019 in Linux / Unix by backtothefuture (551k points) | 630 views
+4 votes
2 answers
asked Oct 11, 2019 in Linux / Unix by backtothefuture (551k points) | 355 views
+4 votes
1 answer
Sponsored articles cost $40 per post. You can contact us via Feedback
10,634 questions
10,766 answers
510 comments
3 users