?Linux startup process:?
日期:2014-05-16 浏览次数:20553 次
?Linux startup process:?
1. inittab file (/etc/inittab)
1. All the entries in inittab file are stored with format below:
id:run-levels:action:process
id --> identifier, usually two alphabets or two degits.
run-levels --> digit from 0-6. multiple run-level can be assigned.
action --> represents the running status
process --> represents the script/command that need to be executed.
process is our main focus, and we can even ignore the id.
action: 1> initdefault: the system default run level 2> sysinit: 3> wait: the command marked wait means the commands after this line can be executed only after the execution of this command. 4> once: start a new process and execute the command, the commands after it don't have to wait the execution of it. 5> ctrlaltdel: the command will be executed when we press ctrl+alt+del 6> powerfail: when there is error with battery/power, the command specified will be executed, and don't have to wait for end of the execution. 7> powerokwait: when the battery/power back to normal, the command specified will be executed. 8> respawn: whenever the command executed, the command should be executed again. It a command execution loop. # Trap CTRL-ALT-DELETE ca::ctrlaltdel:/sbin/shutdown -t3 -r now
Sometimes we may install sendmail, and it will execute when we start up. And its default action is wait, that means other commands have to wait the execution of it. That would take a lot of time.
# Run gettys in standard runlevels 1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2 3:2345:respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty4 5:2345:respawn:/sbin/mingetty tty5 6:2345:respawn:/sbin/mingetty tty6 # In linux, tty means local terminal # We can press ctrl+alt+F1~F6 to shift between different theres terminals. # If we press ctrl+alt+F7/F8 then we will shift to x-window terminal
si::sysinit:/etc/rc.d/rc.sysinit # id -> si # run-levels -> empty means this init script/command should be executed no matter what the current run-level is l0:0:wait:/etc/rc.d/rc 0 # id -> l0 # run-levels -> 0 means only execute "/etc/rc.d/rc 0" when current run level is 0 pr:12345:powerokwait:/sbin/shutdown
2. First effective line in inittab file:
id:5:initdefault
1. The default run-level is 5 which means multi-user and x-window running level.
2. We can modify this line to change the default running level when system startup.
?3. There is no process script assigned in this line, why?
?
?3. Second effective line in inittab file:
si::sysinit:/etc/rc.d/rc.sysinit
1. run-level is empty, means whatever current run-level is, this "etc/rc.d/rc.sysinit" will always be executed.
2. "etc/rc.d/rc.sysinit" is a shell script. If we want an operation executed when the system startups, we can add the command a