Jun 01, 2021 Article blog
1. Centeros/RHEL 7.X's systemd system service view
2. Use the netstat command to view system services
3. View system services from the system service profile
Linux
system services, sometimes referred to as daemons, are system tasks that load automatically when
Linux
starts and stop automatically when
Linux
exits.
In this article, you'll be introduced to how to list all running services in a
Linux
system and how to check the current status of a service.
CentOS 7.x
began,
CentOS
began to use
systemd
services instead of
daemon
and the original system startup and management system services related commands were replaced by
systemctl
commands.
systemctl list-unit-files
The output of the command is as follows:
View all running
systemd
services to run the following commands:
systemctl | more
The output of the command is as follows:
In addition, you can use the following commands:
systemctl list-units --type service
The output of the command is as follows:
If you want to search for a particular service in the results, you can use the pipeline and
grep
commands.
systemctl | grep "apache2"
The output of the command is as follows:
Netstat
command is used to check active network connections, interface statistical analysis, and routing table status.
This command is available in all
Linux
distributions, and we'll use it next to view system services.
View the services and the ports they listen to:
netstat -pnltu
The output of the command is as follows:
The service profile is
/etc/services
an
ASCII
file that contains a series of services that user programs might use.
In this file, the service name, port number, protocol used, and some aliases are included.
For this file, we can view it using any text tool, such as
vim
vim /etc/services
The output of the command is as follows:
In some new versions of
Linux
systems, some
systemd
has been used to replace
init
processes. I
n this system, how to view the system services?
We can use the following syntax:
systemctl status service_name
For example, to see if
OpenSSH
on your system is running, you can run:
systemctl status sshd
The output of the command is as follows:
Alternatively, you can use the following command format to see if a service is running:
systemctl is-active service_name
If you use this command, the corresponding command for implementing the example above is:
systemctl is-active sshd
The output of the command is as follows:
You can also see if a service has been enabled, using the following command:
systemctl is-enabled service_name
For example, to check that
OpenSSH
service is enabled, you might enter the following command:
systemctl is-enabled sshd
The output of the command is as follows:
It can't be said that in the early days, there were still many such systems running on
SysV init
process.
For this system, the command to view the status of the service is:
service service_name status
Or look at an example of
OpenSSH
state with the following command:
service sshd status
The output of the command is as follows:
You can also use the following commands to see all service statuses:
chkconfig --list
The output of the command is as follows:
Here are five ways to view
Linux
system services.
I hope to help you, students interested in
Linux
can take a look at the tutorial
Linux tutorial: https://www.w3cschool.cn/linux/
Linux Microsyscope: https://www.w3cschool.cn/minicourse/play/linuxcourse
Linux should learn this: https://www.w3cschool.cn/linuxprobe/