Red Hat / CentOS Check and List Running Services Linux Command

How do I list all currently running services in Fedora / RHEL / CentOS Linux server? How can I check the status of a service using systemd based CentOS/RHEL 7.x and RHEL/CentOS 8.x?

There are various ways and tools to find and list all running services under a Fedora / RHEL / CentOS Linux systems.

ADVERTISEMENTS

Red Hat / CentOS Check and List Running Services Command

Please note that systemd based system such as CentOS/RHEL 7.x/8.x and latest version of fedora use the systemctl command to list running services

List running services using service command on a CentOS/RHEL 6.x or older

The syntax is as follows for CentOS/RHEL 6.x and older (pre systemd systems):
service --status-all
service --status-all | more
service --status-all | grep ntpd
service --status-all | less

Print the status of any service

To print the status of apache (httpd) service:
service httpd status
Display status of sshd service:
service sshd status

List all known services (configured via SysV)

chkconfig --list

List service and their open ports

netstat -tulpn

Turn on / off service

ntsysv
chkconfig service off
chkconfig service on
chkconfig httpd off
chkconfig ntpd on

ntsysv is a simple interface for configuring runlevel services which are also configurable through chkconfig. By default, it configures the current runlevel. Just type ntsysv and select service you want to run.

Red Hat / CentOS List Running Services using systemctl (RHEL/CentOS 7.x/8.x)

If you are using systemd based Linux distros such as Fedora Linux v22/23/24/26/27/28/29/30/31 or RHEL/CentOS Linux 7.x/8.x. Try the following command to list running services using the systemctl command. It control the systemd system and service manager.

To list systemd services on CentOS/RHEL 7.x+ use

The syntax is:
systemctl
systemctl | more
systemctl | grep httpd
systemctl list-units --type service
systemctl list-units --type mount

To list all services:
systemctl list-unit-files
Sample outputs:

Fig.01: List all units installed on the CentOS /RHEL 7 systemd based system, along with their current states

Fig.01: List all units installed on the CentOS /RHEL 7 systemd based system, along with their current states

To view processes associated with a particular service (cgroup), you can use the systemd-cgtop command. Like the top command, systemd-cgtop lists running processes based on their service:
systemd-cgtop
Sample outputs:

Path                                            Tasks   %CPU   Memory  Input/s Output/s
 
/                                                  85    0.3   240.1M        -        -
/system.slice/NetworkManager.service                2      -        -        -        -
/system.slice/auditd.service                        1      -        -        -        -
/system.slice/crond.service                         1      -        -        -        -
/system.slice/dbus.service                          1      -        -        -        -
/system.slice/lvm2-lvmetad.service                  1      -        -        -        -
/system.slice/polkit.service                        1      -        -        -        -
/system.slice/postfix.service                       3      -        -        -        -
/system.slice/rsyslog.service                       1      -        -        -        -
/system.slice/sshd.service                          1      -        -        -        -
/system.slice/...tty.slice/getty@tty1.service       1      -        -        -        -
/system.slice/systemd-journald.service              1      -        -        -        -
/system.slice/systemd-logind.service                1      -        -        -        -
/system.slice/systemd-udevd.service                 1      -        -        -        -
/system.slice/tuned.service                         1      -        -        -        -
/system.slice/wpa_supplicant.service                1      -        -        -        -
/user.slice/user-0.slice/session-2.scope            1      -        -        -        -
/user.slice/user-1000.slice/session-1.scope         4      -        -        -        -

To list SysV services only on CentOS/RHEL 7.x+ use (does not include native systemd services)

chkconfig --list
Sample outputs:

Fig.02: List Sysv based services on systemd

Fig.02: List Sysv based services on systemd

How to check the status of a service using systemd

Say you want to check status of a service named sshd, run
$ systemctl status sshd.service
Sample outputs:

<span style='color: rgb(0, 153, 0);'>●</span> ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: <span style='color: rgb(0, 153, 0);'>active (running)</span> since Tue 2020-08-04 06:15:53 IST; 17h ago
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 3180 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 3236 (sshd)
      Tasks: 1 (limit: 37952)
     Memory: 2.6M
     CGroup: /system.slice/ssh.service
             └─3236 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
 
Warning: journal has been rotated since unit was started, output may be incomplete.

Verifying the status of a service

One can verify that if a service named sshd is running (active) or not running (inactive) on a CentOS/RHEL 7.x+:
systemctl is-active sshd
systemctl is-enabled sshd
systemctl is-active nginx
systemctl is-enabled nginx
systemctl is-enabled httpd

Check whether a service is running or not running on a CentOS RHEL

Listing RHEL/CentOS 8.x services

We use the following command to find about currently loaded services:
$ sudo systemctl list-units --type=service

UNIT                               LOAD   ACTIVE SUB     DESCRIPTION                           
_____________________________________________________________________________________________________
console-getty.service              loaded active running Console Getty                         
crond.service                      loaded active running Command Scheduler                     
dbus.service                       loaded active running D-Bus System Message Bus              
dracut-shutdown.service            loaded active exited  Restore /run/initramfs on shutdown    
NetworkManager-wait-online.service loaded active exited  Network Manager Wait Online           
NetworkManager.service             loaded active running Network Manager                       
rsyslog.service                    loaded active running System Logging Service                
systemd-journal-flush.service      loaded active exited  Flush Journal to Persistent Storage   
systemd-journald.service           loaded active running Journal Service                       
systemd-logind.service             loaded active running Login Service                         
systemd-resolved.service           loaded active running Network Name Resolution               
systemd-sysctl.service             loaded active exited  Apply Kernel Variables                
systemd-tmpfiles-setup-dev.service loaded active exited  Create Static Device Nodes in /dev    
systemd-tmpfiles-setup.service     loaded active exited  Create Volatile Files and Directories 
systemd-udev-trigger.service       loaded active exited  udev Coldplug all Devices             
systemd-udevd.service              loaded active running udev Kernel Device Manager            
systemd-update-utmp.service        loaded active exited  Update UTMP about System Boot/Shutdown
systemd-user-sessions.service      loaded active exited  Permit User Sessions                  
 
LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
 
18 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

Type systemctl command without any options to show both loaded and active units/services:
$ sudo systemctl
Filter out using the grep command/egrep command:
$ sudo systemct | egerep 'httpd|php-fpm|mysqld|nginx'
$ sudo systemctl list-units --type=service | grep nginx

Listing service/unit dependencies

The syntax is:
# systemctl list-dependencies {service-name}
# systemctl list-dependencies nginx.service
# systemctl list-dependencies php-fpm.service
# systemctl list-dependencies sshd.service
# systemctl list-dependencies crond.service

crond.service
 ├─system.slice
 └─sysinit.target
●   ├─dev-hugepages.mount
●   ├─dev-mqueue.mount
●   ├─dracut-shutdown.service
●   ├─import-state.service
●   ├─kmod-static-nodes.service
●   ├─ldconfig.service
●   ├─loadmodules.service
●   ├─proc-sys-fs-binfmt_misc.automount
●   ├─selinux-autorelabel-mark.service
●   ├─sys-fs-fuse-connections.mount
●   ├─sys-kernel-config.mount
●   ├─sys-kernel-debug.mount
●   ├─systemd-ask-password-console.path
●   ├─systemd-binfmt.service
●   ├─systemd-firstboot.service
●   ├─systemd-hwdb-update.service
●   ├─systemd-journal-catalog-update.service
●   ├─systemd-journal-flush.service
●   ├─systemd-journald.service
●   ├─systemd-machine-id-commit.service
●   ├─systemd-modules-load.service
●   ├─systemd-random-seed.service
●   ├─systemd-sysctl.service
●   ├─systemd-sysusers.service
●   ├─systemd-tmpfiles-setup-dev.service
●   ├─systemd-tmpfiles-setup.service
●   ├─systemd-udev-trigger.service
●   ├─systemd-udevd.service
●   ├─systemd-update-done.service
●   ├─systemd-update-utmp.service
●   ├─cryptsetup.target
●   ├─local-fs.target
●   │ └─systemd-remount-fs.service
●   └─swap.target

Conclusion

For latest version of the CentOS/RHEL 7.x use the systemctl command and for older version try service command to show all services running under Centos or RHEL Server.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
22 comments… add one
  • sankar Jan 22, 2009 @ 7:43

    it is help to view port status and services

  • Diabolic Preacher Jan 23, 2009 @ 15:58

    would these work on a ubuntu-server install? i would really have some use for commands to list running services.

  • 🐧 nixCraft Jan 23, 2009 @ 20:56

    Yes, it should work – if you have sysvconfig package installed.

  • Diabolic Preacher Jan 24, 2009 @ 2:50

    thanks vivek, am hoping its already installed coz on a server you definitely wanna check on services.
    but isn’t it like ubuntu doesn’t follow the SysV model, especially in terms of the init system but has its own upstart something?

  • anderson Jul 1, 2009 @ 17:44

    service httpd mysqld tomcat5 start/stop/restart/status
    chkconfig service on/off
    netstat -tulpn
    ntsysv gui
    service service start is different from chkconfig , when the server is rebooted , service start will not work .

  • Scott Jul 5, 2009 @ 22:41

    In debian/ubuntu, install sysv-rc-conf and sysvinit-utils. That’s the first thing I do on any .deb box. These should be default with debian and ubuntu installs, IMO.

  • dragmore Jan 5, 2010 @ 12:54

    I would love an article discribing all the “default” services in a Centos 5.x installation and which to keep for performance and secrutiy and which to turn off. Basically discribing the more common ones.
    When i list with ntsysv i see a ton i have no clue what really does ;)

  • thiyagi Dec 23, 2010 @ 11:42

    thanks, that was really useful..

  • chanvoeu Feb 9, 2011 @ 8:16

    Dear sir!
    Right now i have some question about Centos.
    i can not configure some main service dns, apache …
    please you help me!!!

  • toto Mar 7, 2011 @ 7:52

    nice information. thank you

  • chapise Nov 24, 2011 @ 1:30

    :D thank you so much dude,

  • t Apr 8, 2013 @ 11:19

    netstat -tulpn

  • garb May 23, 2013 @ 7:27

    For Ubuntu 12.04, you can list service status with 2 commands (first for SysV services and second for upstart services):

    service –status-all
    initctl list

  • deepak Apr 16, 2014 @ 14:45

    hi guys please help me out,
    i have to run “.jar” as service in centos32 machine.
    how can i do that…

  • javeria turk May 22, 2014 @ 7:38

    what services of linux support virtualization?

  • Pauline Feb 9, 2015 @ 9:53

    Hi all,
    I need help on what command should I use to start/stop running services.
    Thanks

  • kalyan Jul 30, 2015 @ 11:22

    Hello Sir,
    i am using RHEL server 5.8 . Now i want to know the list of Services running as per OS level..
    I have executed “service –status-all ” -> it showing Error :bash :: command service not found..
    what ‘s the problem in my case ??
    my info ::: uname -a
    o/p :: Linux NEURAREPO 2.6.18-308.el5 #1 SMP Fri Jan 27 17:17:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
    pls guide me to know the lsit of Services running in my server.thnak you..

  • imran Oct 21, 2015 @ 6:51

    it very helpful for me thnx dear

  • Jhonattan Mar 16, 2016 @ 3:21

    Show all run java service.
    command: pidof java

  • Wouter Bovelander Jun 1, 2016 @ 9:06

    On CentOS7 I had to run

    systemctl

    To list all active services. Service –status-all no longer gives the desired result since systemd handles the init scripts.

  • James Dec 12, 2016 @ 14:25

    I am using RHEL to host Bitbucket/Stash and would like to find out what account is using the service. How can I figure this out other than checking init.d script?

  • Ntuweleni Lucas Phalanndwa Oct 5, 2017 @ 5:41

    My device is reporting that services are not active. Email , notifications, calendar and therefore can not verify my email address.All signed apps are also not active.Please help.(iCloud Drive is not active, backup not active,and can not save documents, Keynote, Pages, numbers can not work if the email is not verified).

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.