What is the recommended way of checking running services?

55,529

Solution 1

I want to know: what is the recommended method of checking all running services across these systems?

Since you are aware of chkconfig,service, and may be ntsysv,rcconf,

but you can check using below command which almost work in all flavor

ls -1 /etc/rc$(runlevel| cut -d" " -f2).d/S*

What is S* ?

the traditional init style makes symlinks that start with S, or K. those with S means "start", and they are run with the "start" parameter when that runlevel is entered. Those with K means "kill", those services are run with the "stop" parameter when that runlevel is entered

Full details:

ls -1 /etc/rc$(runlevel| cut -d" " -f2).d/S* | \
awk -F'[0-9][0-9]' '{print "Startup :-> " $2}'

Output:

Startup :-> bind9
Startup :-> apt-cacher-ng
Startup :-> slapd
Startup :-> cron
Startup :-> dmesg
Startup :-> inetutils-inetd
Startup :-> ssh
Startup :-> dns-clean
Startup :-> sudo
Startup :-> apache2
Startup :-> grub-common
Startup :-> ondemand
Startup :-> rc.local

Solution 2

A little less elegant but you can always compare what is running ps aux against what is listed in /etc/init.d/ or /etc/rc.d/

Share:
55,529

Related videos on Youtube

synack
Author by

synack

Current interests [July 2013] : Computer networks, Network/webapp security, Virtualization, c/c++ and C# programming (beginner stages.)

Updated on September 18, 2022

Comments

  • synack
    synack over 1 year

    I'm often exposed to various GNU/Linux systems including CentOS, SLES and Debian.

    I want to know: what is the recommended method of checking all running services across these systems?

    I am aware of service --status-all and chkconfig but they are not always available.

    Please advise.

  • synack
    synack almost 11 years
    Any Debian-like equivalent to this?
  • synack
    synack almost 11 years
    Nice answer, although you might want to correct your spelling of chkconfig for future readers.
  • Rahul Patil
    Rahul Patil almost 11 years
    @synack Thanks.. I have corrected that.. if this answer satisfy you, So can you mark it as correct.
  • Pablo A
    Pablo A over 6 years
    In my case (Ubuntu 16.04) your command list -> 41, rcconf --list | grep " on$" | wc -l -> 56, service --status-all | grep -F "[ + ]" | wc -l -> 47, systemctl list-unit-files --state=enabled -> 73. Why this might be? Just enabled vs running?