+5 votes
284 views
Command to view active services in CentOS Linux

in Linux / Unix by (552k points)
reopened | 284 views

1 Answer

+3 votes
Best answer

1. How to view and manage active services in CentOS 7 Linux
2. How to check the status of a service using Systemd in CentOS Linux

Each and every one of the current operating systems is based on various services that are responsible for delivering the best options for the applications and other system components to function properly..

Thanks to the services it will be possible to use in full each functionality available in the operating system used; and it is important, at the level of administration and audit tasks , to know in detail what services are active in real time, which can help us not only to have a complete list of these but also to determine if any of them is causing a negative effect on the general behavior of the operating system.

For this reason TechnoWikis will explain some of the different ways to know the active services in CentOS 7 and thus have a better control over them..

Note
CentOS 7 makes use of the systemctl command, which controls the systemd system and the system services administrator, so that through this command we can access the active services.
List services in CentOS 6

If you use CentOS 6 as an administration system, we have the following lines to access the detail of active services:
 service --status-all service --status-all | more service --status-all | grep ntpd service --status-all | them 
For example, to print the status of Apache services we execute the following:
 service httpd status 
If the goal is to list all known services we will execute:
 chkconfig –list 
To list the services and their respective open ports we execute:
 netstat -tulpn 
To activate or not the service we have the following lines:
 ntsysv chkconfig service off chkconfig service on chkconfig httpd off chkconfig ntpd on 

1. How to view and manage active services in CentOS 7 Linux


Step 1

For this tutorial we will use CentOS 7 and to list all the distribution services we execute:
 Systemctl 
We can see details like
  • Service name
  • Loading time
  • Activity status
  • Service description

image

Step 2

If we wish to obtain more information we will execute:
 systemctl | more 
We will see the following. At the bottom we can select the "More" line to access more service records.

image

Step 3

We can list a particular service or user with the following syntax:
 systemctl | grep “service / user” 

image

Step 4

To list only the services we will execute the following:
 systemctl list-units --type service 

image

Step 5

Now, if we want to list all the records that have been mounted on the unit:
 systemctl list-units --type mount 

image

Step 6

To list all services regardless of their status we will execute the following:
 systemctl list-unit-files 
The result will be as follows:

image

Step 7

It is possible to visualize the processes associated with a particular service like cgroup, for this case we must use the command To see the processes associated with a particular service (cgroup), you can use the systemd-cgtop command, within the displayed results, we can see the processes in execution according to the type of service, for this we execute.
 systemd-cgtop 
There we can see each service with the respective use of resources such as CPU, memory, inputs and outputs, etc.

image

Step 8

Another option in the tasks about the services, is to list the SysV services in use, this does not include the native systemd services. To perform this action we must execute the following:
 chkconfig –list 

image


2. How to check the status of a service using Systemd in CentOS Linux


Step 1

To verify the status of a real-time service we will execute the following syntax:
 systemctl status "service" 
For example, we can validate the status of the SSHD service:
 systemctl status sshd.service 
In this case we can see that its status is active and all the actions that have been executed with the selected service are listed.

image

Step 2

To verify if a service is running (active) or not running (inactive) in CentOS 7 we can use the following options:
 systemctl is-active sshd systemctl is-enabled sshd systemctl is-active nginx systemctl is-enabled nginx systemctl is-enabled httpd 
There we can visualize the different states including unknown which indicates that the service is unknown because it does not exist in the system.

image

This will make it possible to have a much more precise administration of services in CentOS 7.


by (3.5m points)
edited

Related questions

+5 votes
1 answer
+3 votes
1 answer
asked Nov 16, 2019 in Linux / Unix by backtothefuture (552k points) | 652 views
+3 votes
1 answer
asked Nov 14, 2019 in Linux / Unix by backtothefuture (552k points) | 416 views
+4 votes
2 answers
asked Oct 11, 2019 in Linux / Unix by backtothefuture (552k points) | 386 views
+4 votes
1 answer
asked Oct 14, 2019 in Linux / Unix by backtothefuture (552k points) | 273 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users