"Linux"/etc/inittab file detailed __linux

Source: Internet
Author: User
Tags terminates

The original site is as follows:

http://leejia.blog.51cto.com/4356849/788895


/etc/inittab Document Detailed

The Linux boot process is: Power On self-test--> boot--> from a specified device, based on the settings in the BIOS locate the bootloader boot boot system in the device MBR--> boot kernel--> start the init process     We see that the final start of the Linux system is to start the init process, and how the init process works. The init process is based on/etc/inittab this file to start the corresponding process at different run levels or to perform the appropriate action.         /etc/inittab the registration entries defined in this file are: Four segments separated by:       Id:runlevels:action:process         ID: It is an identifier for each entry that uniquely identifies each entry and cannot repeat the       Runlevels: The running level of the system that represents the level at which the process action is to run, in which you can define multiple run levels, write without delimiters between levels, or null to run at all run levels. Linux runs at the level of:     0: Shutdown     1: Single user mode, in this mode, the user login does not require a password, the default network card driver is not loaded, some services can not be used.     2: Multiuser mode, NFS service does not open     3, indicating command-line mode     4, this mode is reserved for     5, which indicates graphic user mode     6 , which means the reboot system       action: Represents the action to be performed by the process of the corresponding registration entry under certain conditions.     Specific actions are:     respawn: Start a new     after the process terminates: The process will not start once after entering the specified runlevels And to leave this runlevels terminate     Initdefault: Set the default run level, that is, the default level of operation after we boot, can not be 0, 6, you know     SysinIt: System initialization, only when the system is powered on or restarted, this process is executed once     powerwait: When Init receives a power failure signal, it executes the corresponding process, and if Init has a process running, Waits for the process to complete, then executes the corresponding process     Powerfail: When Init receives a power failure signal, it executes the corresponding process, and if Init has a process running, it will not wait for the process to complete. It executes the corresponding process     powerokwait directly: The power supply has failed, but the corresponding process     is executed while waiting for the corresponding operation to occur. Powerfailnow: When a power failure and INIT is notified that the UPS power supply is running out of the corresponding process     Ctrlaltdel: When the user presses Ctrl+alt+del This key combination, executes the corresponding process     Boot: The process is executed only during the boot process, but not the end of the process, and when the process dies, the process is not restarted     bootwait: The process is executed only during the boot process and waits for the end of the process , and does not restart the process     off when the process is dead: If process is running, a warning signal is issued, waiting for 20 seconds, and then forcibly terminated by killing the signal. If the process does not exist then ignore the registration entry     Once: start the appropriate process, but continue processing the next entry in the/etc/inittab file without waiting for the process to finish; Init does not restart the process when the process dies       Process: Indicates which program or script to start or which command to execute, and so on         to Redhat Enterprise Server 5.4 for example. We analyze the/etc/inittab file:     The beginning of "#" is the comment line, no effect          Id:3:initdefault:     First field as an identifier, we won't say it below. This entry indicates our default run levelis 3, which means that our default boot boot will enter the command line mode.       Si::sysinit:/etc/rc.d/rc.sysinit     All run levels, Init relies on/etc/rc.d/rc.sysinit This script to initialize the system. The main functions of/etc/rc.d/rc.sysinit are:     1, activating Udev and SELinux     2, setting kernel parameters according to/etc/sysctl.conf file     3, set system clock     4, keyboard key mapping, that is, identify keyboard     5, enable swap partition     6, set host name     7, root file system detection and re-read and write mode Mount &NB Sp   8, activate raid and LVM devices     9, enable disk quotas     10, Detect and mount other file systems (mount the device defined in/etc/fstab)     11, clear expired locks and PID files       L0:0:WAIT:/ETC/RC.D/RC 0     L1:1:WAIT:/ETC/RC.D/RC 1     L2:2:WA IT:/ETC/RC.D/RC 2     L3:3:WAIT:/ETC/RC.D/RC 3     L4:4:WAIT:/ETC/RC.D/RC 4     l5:5:wait:/e TC/RC.D/RC 5     L6:6:WAIT:/ETC/RC.D/RC 6     When entering the n run level (n is the run level defined above), the/ETC/RC.D/RC*.D (* Indicates the number of the corresponding registration entry Process field RC The file that starts with s in this directory is enabled and the files that begin with K are disabled, and the files are only executed once when they enter the appropriate run level, and exit this run level failure. So each run-level service is independent, and/ETC/RC.D/RC*.D this directory is a file of services that are opened and disabled at the corresponding level.   &nbsp   Ca::ctrlaltdel:/sbin/shutdown-t3-r now      at all run levels, wait 3 seconds after pressing Ctrl+alt+del to reboot the system. That's why we press these three keys to reboot the system       PF::p owerfail:/sbin/shutdown-f-H +2 "power failure; System shutting down "    at all levels of operation, if a power failure occurs, a prompt is given and the computer shuts down after 2min.       pr:12345:powerokwait:/sbin/shutdown-c "Power restored; Shutdown cancelled "    at 12345 run level, if the power supply failure, the power is back to normal, then give the message, and immediately terminate the shutdown.       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     at 2345 run level, 6 command line interface terminals will be enabled, and once the terminal is terminated, will be creating a new one. That's why our system will have 6 command-line interfaces at the end of the line.       X:5:respawn:/etc/x11/prefdm-nodaemon     Only if we go into the 5 run level, the graphical user terminal will open, and once the terminal terminates, a new one will be created. If you delete this line, will your graphical interface still work? You know       Thus on. Are you with Lin?UX knows a lot about it. Come on.

There is also an article, the original site is as follows:

Http://www.linux178.com/linux/inittab.html
Detailed/etc/inittab document Author: Spartacus Time: January 4, 2014 Category: Linux

When the kernel is initialized, the first process is started Init,init processes perform a series of system initialization, and Init is initialized based on what.

Init reads the/etc/inittab file (for the CentOS 5 series), executes the contents to initialize, and the file is in a certain format.

get help with the Inittab file, enter the man inittab command

Filter out blank lines and lines starting with the # number, as follows:

[Root@server1 ~]# egrep-v ' ^$|^# '/etc/inittab
id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit
l0:0 : WAIT:/ETC/RC.D/RC 0
L1:1:WAIT:/ETC/RC.D/RC 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
L4 : 4:WAIT:/ETC/RC.D/RC 4
L5:5:WAIT:/ETC/RC.D/RC 5
l6:6:wait:/etc/rc.d/rc 6
ca::ctrlaltdel:/sbin/ Shutdown-t3-r now
PF::p owerfail:/sbin/shutdown-f-H +2 "power failure; System shutting down the "
pr:12345:powerokwait:/sbin/shutdown-c" power restored; Shutdown cancelled "
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2,345: Respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty
tty5 6:2345:respawn:/sbin/mingetty Tty6
X:5:respawn:/etc/x11/prefdm-nodaemon

The format can be summed up as follows:

Id:runlevels:action:process

ID is used to define the unique entry number for the Inittab file, 1-4 characters long
Runlevels list to run the level is null to represent all levels
Actions to be performed by the action
Procedure to be executed by the process

Id:3:initdefault:

ID is defined by using the ID itself
3 is the running level listed
Initdefault
This action is to set the default run level, if the previous runlevels does not specify the running level, then at the start of the terminal query, this line does not need to process this section

Si::sysinit:/etc/rc.d/rc.sysinit

ID is Si is only used to identify
Runlevels is null to represent all run levels
Sysinit is the execution of the following process (i.e.,/etc/rc.d/rc.sysinit) when the system starts.
/etc/rc.d/rc.sysinit This is a system initialization script that initializes a lot of

The role of the script:

Activate SELinux and Udev set
kernel parameters according to/etc/sysctl.conf file set
system clock
mount key mapping
enable swap partition
set host name
root file system detect and reload it as read and write;
activate Raid and LVM;
Check and mount other file systems;/etc/fstab definition;
cleanup operations
L0:0:WAIT:/ETC/RC.D/RC 0

L0 is the mark, this is level 0.
0 is that the action takes place at level 0.
Wait refers to the following process (/ETC/RC.D/RC 0) When you switch to level 0, and the init process waits until those processes terminate
/ETC/RC.D/RC 0 This is a script after 0 is passed in the parameter, passing in 0 represents to perform the/etc/rc.d/rc0.d/
All of the following scripts first execute the script at the beginning of K and then execute the script that begins with S
This line means that when running at level 0, all scripts are executed/etc/rc.d/rc0.d/

The script at the beginning of K has to be stopped.
Scripts that start with S need to be started

The 2-digit number that follows is the start or stop sequence.

Most of this is the beginning of K, because level 0 is shut down in itself, so all are to stop, there are 2 s to start s00killall This script kill all the process is not closed, S01halt is used to shut down all the 2 s to start the script

L1:1:WAIT:/ETC/RC.D/RC 1
L2:2:WAIT:/ETC/RC.D/RC 2
l3:3:wait:/etc/rc.d/rc 3
L4:4:WAIT:/ETC/RC.D/RC 4
L5:5:WAIT:/ETC/RC.D/RC 5
L6:6:WAIT:/ETC/RC.D/RC 6

These are just like the ones above.

Ca::ctrlaltdel:/sbin/shutdown-t3-r now

CA ID Name
RunLevel blank to represent all levels
Ctrlaltdel Representative Ctrl+alt+delete
/sbin/shutdown-t3-r now executes the reboot command

PF::p Owerfail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.