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


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


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.

  • This answer was not brought to you by the number 328185 and the letter K. (-: – JdeBP Mar 1 '19 at 1:00
  • Fair point. Have edited to correct. – Philip Couling Mar 1 '19 at 1:23

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.