In this article, I will show you how to list all running services on Linux. We will also check how to check the status of a service on a systemd system.
Let's learn different commands used to list services on Centos/RHEL 7.x.
Check and Listing linux services (systemd on Centos/RHEL 7.x)
To list systemd services we will use systemctl command as below
# systemctl list-unit-files
To list active systemd services run
# systemctl | more
Another command you can use is
# systemctl list-units --type service
You can pipe the output to grep to search a more specific service as shown below
# systemctl | grep "apache2"
Listing services using Netstat Command
Nestat command is a tool used for examining active network connections, interface statistics as well as the routing table. It's available in all Linux distributions and here we will check how to list services using netstat command.
To check the services alongside the ports they are listening.
# netstat -pnltu
Viewing /etc/services file
/etc/services is an ASCII file that contains information about numerous services that client applications might use on the computer. Within the file is the service name, port number and protocol it uses, and any applicable aliases. ITO put t indicates whether a service is TCP or UDP and the name it goes by according to IANA. This information is helpful especially if you are unsure which service is running on which port by default.
To get a clearer picture, view the
/etc/services file using a text editor of your choice.
Systemd services status check
In newer versions of Linux, Systemd init is present. To check if a service is running, use the syntax below
# systemctl status service_name
For example, to check if OpenSSH is running on your system, run
# systemctl status sshd
Alternatively, you can use the syntax below to check if the service is active
# systemctl is-active service_name
In this case, to check if OpenSSH is active, execute
# systemctl is-active sshd
Also, you can use the command below to check if a service is enabled
# systemctl is-enabled service_name
To check if OpenSSH is enabled, run
# systemctl is-enabled sshd
Checking the status of services in older systems (Centos/Rhel 6.x)
For systems running SysV Init, you can check the status of services by running
# service service_name status
For example, to check the status of OpenSSH, run
# service sshd status
You can also check all services by running
# chkconfig --list
We hope you found this article useful. Feel free to try out some of the systemd commands listed here.