How to List Services in Linux

How to list all running services in linux

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

Sample Output

systemctl list-unit-files

To list active systemd services run

# systemctl | more

Sample Output

systemctl command

Another command you can use is

# systemctl list-units --type service

Sample Output

systemctl list-units --type service

You can pipe the output to grep to search a more specific service as shown below

# systemctl | grep "apache2"

Output

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

Output

netstat -pnltu

Viewing /etc/services file

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

vim /etc/services

Output

check running services ports

Systemd services status check

In newer versions of Linux, Systemd init is present. To check if a service is running, use the syntax below

Syntax

# systemctl status service_name

For example, to check if OpenSSH is running on your system, run

# systemctl status sshd

Output

check running services

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

Output

check running services/ports

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

Output

check running services

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

Output

service sshd status

You can also check all services by running

# chkconfig --list

Output

chkconfig --list

We hope you found this article useful. Feel free to try out some of the systemd commands listed here.

Winnie Ondara 12:19 pm

About Winnie Ondara

I’m Winnie, a passionate Linux administrator and an open source enthusiast. I enjoy keeping myself up to date with the latest in the Linux world and trying out the latest tools, features and services in the FOSS community.

Author's All Posts
Like to become part of Linoxide Team and contribute tips? Contact us here.

Comments

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.