11

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.

7

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
  • Nice answer, although you might want to correct your spelling of chkconfig for future readers. – synack Jul 9 '13 at 20:28
  • @synack Thanks.. I have corrected that.. if this answer satisfy you, So can you mark it as correct. – Rahul Patil Jul 9 '13 at 20:55
  • 1
    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? – Pablo Bianchi Oct 1 '17 at 2:59
1

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/

-1

Try with the svcs. svcs should list all the services offline online or maintenance mode..

  • Any Debian-like equivalent to this? – synack Jul 9 '13 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.