Understanding init.d Directory In Linux Filesystem.

init.d is the sub-directory of /etc directory in Linux file system. init.d basically contains the bunch of start/stop scripts which are used to control (start,stop,reload,restart) the daemon while the system is running or during boot. If you look at /etc/init.d then you will notice all the scripts for different services of your system.

The scripts within the directory varies as per the applications installed in your system. In server system you’ll find many network related scripts while in desktop there will be the only basic ones like ‘networking’.

init_main_featureimage

There are two types of scripts :  K scripts & S scripts.

K scripts are known ‘kill’ scripts while S scripts are known as ‘startup’ scripts. Kill scripts always run before startup scripts. The configuration file (.conf) of these scripts are located under /etc/init & the scripts that are used as defaults are located under /etc/default.

Within /etc/init.d you’ll find the script rc.local ,this script is automatically executed after all primarily priortized scripts are executed. Which means first K scripts are executed, following by S scripts, then all other remaining init level scripts (if there’s any) & finally rc.local script.

init_pic2

init_pic3

Now to control any script, you’ll need the superuser (sudo/su) permission. You can manually control the scripts using console/terminal. The syntax for controlling the script is like :

Where <script>  stands for the name of the script located under /etc/init.d which you wanna control, and <option> can be replaced by the control commands like : start,stop,reload,restart,force-reload.

Example :

I hope this helps to understand /etc/init.d directory. This was basic understanding of init.d directory, there’s more into it which will be covered soon.

6 Comments

  1. Your blog is extremely interesting. I am an aspiring developer and have found the information contained here very informative. I think you guys have a great premise for a blog. Keep up the good work. Cheers.

    • Hello David,
      We’re glad that you liked our blog, it pushes us forward to write more detailed technical articles. Keep visiting, mate.

  2. Very nicely written.

  3. Well done, thanks. I think it’s worth noting that this applies to Debian-based Linux systems, as some others use different init systems.

    Keep up the great work!

  4. Hi, I’m a regular reader of your blog, this is really very helpful article 🙂

    Great work!

Leave a Reply

Your email address will not be published. Required fields are marked *