Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

5 ways to take you to view Linux system services


Jun 01, 2021 Article blog


Table of contents


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.

Centeros/RHEL 7.X's systemd system service view

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:

 5 ways to take you to view Linux system services1

View all running systemd services to run the following commands:

systemctl | more

The output of the command is as follows:

 5 ways to take you to view Linux system services2

In addition, you can use the following commands:

systemctl list-units --type service

The output of the command is as follows:

 5 ways to take you to view Linux system services3

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:

 5 ways to take you to view Linux system services4

Use the netstat command to view system services

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:

 5 ways to take you to view Linux system services5

View system services from the system service profile

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:

 5 ways to take you to view Linux system services6

View the status of the systemd service

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:

 5 ways to take you to view Linux system services7

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:

 5 ways to take you to view Linux system services8

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:

 5 ways to take you to view Linux system services9

View of service status in earlier versions

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:

 5 ways to take you to view Linux system services10

You can also use the following commands to see all service statuses:

chkconfig --list

The output of the command is as follows:

 5 ways to take you to view Linux system services11

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/