Linux – How to determine the order of services that start from /etc/init.d

linuxsysvinit

ls -l /etc/init.d/ gives me a list of services are that are started on linux. How do I know the order in which the services are started?

Like if ls -l /etc/init.d/ lists out

serviceA
serviceB
serviceC

I want to know whether serviceB starts before serviceA and all. I want to know the oder of start

Best Answer

The /etc/init.d/ directory is not used. The actual directory used will be one of the /etc/rc*.d directories. Which one is dependent on which run-level your system enters. Typically you startup in runlevel 5 /etc/rc5.d/.

So if you want to find the order scripts will run in start there. The order these scripts are run depend on the name of symbolic link contained in the /etc/rc*.d directory. Scripts beginning with an S are executed when you enter the run level (at boot). Scripts beginning with a D are executed when it leaves this run level (eg: shuts down). Scripts are executed in file name order. That's why the symbolic links in these directories are named with numbers to put them in the "right" order.

So short answer... LC_COLLATE=C ls -l /etc/rc5.d whatever order that prints is the order they will run.

Related Question