Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When the init process is executed when the kernel has loaded, does it read the /etc/inittab file in a top down approach i.e. it executes each line as it appears in the file.

If so and based on my reading and understanding, does this mean that it enters the documented run level and then launch sysinit process or vice versa?

For example the common examples I have seen are

id:3:initdefault:

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit
share|improve this question

2 Answers 2

up vote 4 down vote accepted

First, note that the format of inittab is like so:

Identifier:RunLevel:Action:Command

The key point here being the runlevel. Given the following example code:

a:3::
b:123::
c:23::
d:123::
e:23::

Then the order of execution of the various IDs, starting from runlevel 1 would be:

init 1:  b d
init 2:  c e
init 3:  a
overall: b d c e a

As you can see, it will run them in the order that they are listed in the file, group by runlevel! Also remember, if the identifier is not in the specified runlevel, it will be issued a SIGTERM and then a SIGKILL.

share|improve this answer
    
M - I don't quite follow why you would have multiple run levels for each identifier. –  PeanutsMonkey Apr 11 '12 at 23:41
    
The runlevel says "only run the items specified for that runlevel." So for example, if I say init 3 (move to runlevel 3), then a will start. If I say init 2 (move to runlevel 2), then a will be killed because its not set to run at that runlevel. –  Andrew M. Apr 12 '12 at 2:17
    
I take it when you say items you mean services or processes. Is that right? –  PeanutsMonkey Apr 12 '12 at 19:02
1  
When you move from one runlevel to the next, if the specified command is not allowed, it will be issued a SIGTERM (which is a "Would you please end now? Thank you!") but, if it doesn't respond, will be issued a SIGKILL, which forcibly revokes the memory and process space. I believe the average time is ~10 seconds, but most processes at that level will behave nicely. –  Andrew M. Apr 17 '12 at 5:35
1  
@LunarMushrooms: No, because b and d have already been launched at runlevel 1. –  Andrew M. May 30 '13 at 20:15

It is not a script that is processed in any particular order. It is a configuration file that tells the system what script/commands to run for a particular event or run level. The order of the entries in the file will make no difference, and you can have multiple scripts or commands for each run level.

the first line you show "id:3:initdefault:" tells the system the default run level is 3 => multiuser mode for most flavors.

the "si::sysinit:..." line tells the system to run the script /etc/rc.d/rc/sysinit upon system initialization (runs when the system boots).

if you man inittab, you should get a list of all the options for the file.

share|improve this answer
    
Yes but does that mean that it enters the run level first and then executes the /etc/rc.d/rc/sysinit file or does it execute the file first and then enters the run level followed by the corresponding run level scripts. –  PeanutsMonkey Apr 12 '12 at 0:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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