The /etc/init.d directory contains the scripts executed by init at boot time and when the init state (or "runlevel") is changed.
These scripts are referenced by symbolic links in the /etc/rcn.d directories. When changing runlevels, init looks in the directory /etc/rcn.d for the scripts it should execute, where n is the runlevel that is being changed to, or S for the boot-up scripts.
The names of the links all have the form Smmscript or Kmmscript where mm is a two-digit number and script is the name of the script (this should be the same as the name of the actual script in /etc/init.d).
When init changes runlevel first the targets of the links whose names start with a K are executed, each with the single argument stop, followed by the scripts prefixed with an S, each with the single argument start. (The links are those in the /etc/rcn.d directory corresponding to the new runlevel.) The K links are responsible for killing services and the S link for starting services upon entering the runlevel.
For example, if we are changing from runlevel 2 to runlevel 3, init will first execute all of the K prefixed scripts it finds in /etc/rc3.d, and then all of the S prefixed scripts in that directory. The links starting with K will cause the referred-to file to be executed with an argument of stop, and the S links with an argument of start.
The two-digit number mm is used to determine the order in which to run the scripts: low-numbered links have their scripts run first. For example, the K20 scripts will be executed before the K30 scripts. This is used when a certain service must be started before another. For example, the name server bind might need to be started before the news server inn so that inn can set up its access lists. In this case, the script that starts bind would have a lower number than the script that starts inn so that it runs first:
The two runlevels 0 (halt) and 6 (reboot) are slightly different. In these runlevels, the links with an S prefix are still called after those with a K prefix, but they too are called with the single argument stop.
Also, if the script name ends in .sh, the script will be sourced in runlevel S rather than being run in a forked subprocess, but will be explicitly run by sh in all other runlevels.
0 comments to "What is init.d ?"
Powered by WidgetsForFree
- ► 2013 (19)
- ► 2011 (18)
- ► 2010 (35)
- ► 2009 (73)
- Binary Digit Conversion
- DB2 FAQ's
- Trip to Madurai - Rameswaram - Kanyakumari - 3
- Trip to Madurai - Rameswaram - Kanyakumari - 2
- FireFox -3 Out now !!
- Trip to Madhurai-Rameswaram-Kanyakumari - 1
- How to transfer files between 2 windows machines ?...
- Network Calculators - Subnet Mask Calculator
- WWW - W3 Schools
- Web Pages - HTML Colors
- HTML Validation and Optimization
- Games !!!!!
- Distance between main cities
- How to see full command with PID
- ls and grep in windows
- Bash for HP
- Trip (Sashay) To Madhurai - Rameswaram - Kanyakuma...
- Why to Chant Vishnu Sahsranamam ?
- What is a zombie process?
- What is init.d ?
- How to use Arrays in writing shell scripts
- My SQL Basic FAQ's
- NMS & EMS
- Curriculum Search
- ▼ June (25)
My Blog List
- Airtel and vodafone GPRS settings for pocket PC phones
- Andhra 2 America
- Ayyappa Deeksha required things
- Blogs I watch !
- Captions for your bike
- DB2 FAQs
- Deepavali Vs The Goddes of sleep
- ETV - Dhee D2 D3
- Evolution of smoking in India Women
- How to make credit card payments?
- Java-J2EE interview preparation
- My SQL FAQs
- My Travelogues
- Old is blod - New is italic
- Online pay methids for credit cards
- Oracle FAQs
- Smoking in Indian Women
- Technology Vs Humans
- Twitter feeds for all Telugu stars on single page.
- Unix FAQs
- Unix best practices
- init 0, init 1, init 2 ..
- mCheck Application jar or jad download