First, what is init:
INIT is an indispensable program in Linux system operations.
The so-called init process, it is a user-level process that is started by the kernel.
The kernel starts self-launch (already loaded into memory, start running, and has initialized all device drivers and data structures, etc.), the boot process is completed by launching a user-level programin init. So, init is always the first process (its process number is always 1).
The kernel severages several places that INIT have used in the past, and its correct position (for Linux systems) is / sbin / init. If the kernel can't find init, it will try to run / bin / sh. If the operation fails, the system starts will fail.
Second, the run level
So what is the run level?
Simply put, the run level is the functional level of the operating system is currently running. This level has different functions from 1 to 6.
Different run levels are as follows: (You can refer to the / etc / inittab in Red Hat Linux)
# 0 - Down (10 million can not set the initDefault to 0)
# 1 - Single user mode
# 2 - Multiple users, no NFS
# 3 - Complete multi-user mode (standard running level)
# 4 - Nothing
# 5 - x11 (xwindow)
# 6 - Restart (Don't set the initDefault to 6)
These levels are specified in the / etc / inittab file. This file is the main file of the init program, the first running service is filed in the /etc/rc.d directory. In most Linux release versions, the startup script is located in /etc/rc.d/init.d. These scripts are connected to the /etc/rc.d/rcn.d directory with the ln command. (The N is running grade 0-6), each of which links to the commands in init.d.
Third, the configuration of the run level
The configuration of the running level is in / etc / inittab, as shown below:
12: 2: Wait: / etc / init.d / rc 2
The first field is an arbitrary specified label;
The second field indicates that this line is suitable for running that level (here 2);
When the third field indicates when entering the run level, init should run commands within the fourth field, and init should wait for the command to end. The /etc/init.d/rc command runs the startup and termination input to enter any of the commands required to enter the run level 2.
The command in the fourth field performs everything "mixed" when setting the run level. It starts a service that has not been run, and the service should not be run in the new run level. Depending on the version of the Linux version, the specific commands employed are different, and the configuration of the run level is also different.
When INIT starts, it will find a line of code in / etc / inittab, which specifies the default run level:
ID: 2: INitDefault:
You can ask init to enter a non-default run level when starting, which is achieved by specifying a "single" or "Emergency" command line parameter for the kernel. For example, the specification of the kernel command line parameters can be executed by LILO. In this way, you can choose a single user mode (ie the run level 1).
When the system is running, the Telinit command changes the run level. When the run level changes, init will run the corresponding command from the / etc / inittab.
Fourth, special configuration in / etc / inittab
In / etc / inittab, there are several special features that allow init to reactivate special events. These special features are marked with a special keyword in the third field. For example: 1. Powerwait
When INIT is turned off when the power is cut off, the system is turned off. Its premise is that the software with u p s and monitors U P S and notifies the INIT power supply has been cut.
2. Ctrlaltdel
Allow init to restart the system when the user presses the C T R L A L T D E L in the console keyboard. Note that if the system is placed in a public place, the system administrator can configure the C T R L A L T D E l to configure other behavior, such as ignore, etc.
3. Sysinit
The system is ready to run when the system starts. For example, this command will clear / TMP.
The special keywords listed above are incomplete. Other keywords and usage details, you can refer to your inittab man page.
5. Guide in single user mode
An important run level is single user mode (running level 1), in which only one system administrator uses a specific machine and runs system services as little as possible, which contains login. Single user mode is necessary for minority management tasks (such as running fsck on / usr partition), as this requires uninstall partition, but it is impossible unless all service systems have been killed.
A running system can enter a single user mode, and the specific practice is to use init, request the run level 1. When the kernel is started, you can enter the run level 1 when the kernel command line specifies the SINGLE or EMERGENCY keyword. The kernel is also specified for the command line for the init, and initiates from the keyword you should not use the default run level (the input method of the kernel command line is related to the way you start the system).
Sometimes, it is necessary to start in a single user mode, so that the user can manually run FSCK before loading the partition, or at least before being loaded into the dispersed / usr partition, can manually run FSCK (on the dispersed file system, any activity It may make it more dispersed, so fsck should be run as much as possible).
If the automated FSCK fails at startup, the running script init will automatically enter the single user mode. This is to prevent the system from using a non-coherent file system, this file system is F S C K cannot be automatically repaired. The phenomenon of non-coherent file system is extremely rare, and it usually causes unconstabilistic or experimental kernels of the hard disk, but it is best to prevent it.
Due to security considerations, in single user mode, the configured system is required to provide the user to provide the root password before starting the housing script. Otherwise, it will simply enter the right line of code for LILO, log in as root (of course, if the / etc / passwd has not been suitable for the problem of the file system, it is not suitable for this principle, to deal with this Situation, you'd better prepare a label on time).
Different runners have different uses, and should be set according to their own different situations.
For example, if the root password is lost, you can get the machine to start entering the single user status. Enter the LILO prompt after startup:
INIT = / bin / sh rw enables the machine to enter the run level, and hang the root file system is read or written. He will skip all system certifications, allowing you to use the Passwd program to change the root password, then start to a new run level.
The configuration of the running level is in / etc / inittab, as shown below:
12: 2: Wait: / etc / init.d / rc 2 The first field is an arbitrary specified label;
The second field indicates that this line is suitable for running that level (here 2);
When the third field indicates when entering the run level, init should run commands within the fourth field, and init should wait for the command to end. The /etc/init.d/rc command runs the startup and termination input to enter any of the commands required to enter the run level 2.
The command in the fourth field performs everything "mixed" when setting the run level. It starts a service that has not been run, and the service should not be run in the new run level. Depending on the version of the Linux version, the specific commands employed are different, and the configuration of the run level is also different.
When INIT starts, it will find a line of code in / etc / inittab, which specifies the default run level:
ID: 2: INitDefault:
You can ask init to enter a non-default run level when starting, which is achieved by specifying a "single" or "Emergency" command line parameter for the kernel. For example, the specification of the kernel command line parameters can be executed by LILO. In this way, you can choose a single user mode (ie the run level 1).
When the system is running, the Telinit command changes the run level. When the run level changes, init will run the corresponding command from the / etc / inittab.
Fourth, special configuration in / etc / inittab
In / etc / inittab, there are several special features that allow init to reactivate special events. These special features are marked with a special keyword in the third field. such as:
Powerwait
When INIT is turned off when the power is cut off, the system is turned off. Its premise is that the software with u p s and monitors U P S and notifies the INIT power supply has been cut.
2. Ctrlaltdel
Allow init to restart the system when the user presses the C T R L A L T D E L in the console keyboard. Note that if the system is placed in a public place, the system administrator can configure the C T R L A L T D E l to configure other behavior, such as ignore, etc.
3. Sysinit
The system is ready to run when the system starts. For example, this command will clear / TMP.
The special keywords listed above are incomplete. Other keywords and usage details, you can refer to your inittab man page.
5. Guide in single user mode
An important run level is single user mode (running level 1), in which only one system administrator uses a specific machine and runs system services as little as possible, which contains login. Single user mode is necessary for minority management tasks (such as running fsck on / usr partition), as this requires uninstall partition, but it is impossible unless all service systems have been killed.
A running system can enter a single user mode, and the specific practice is to use init, request the run level 1. When the kernel is started, you can enter the run level 1 when the kernel command line specifies the SINGLE or EMERGENCY keyword. The kernel is also specified for the command line for the init, and initiates from the keyword you should not use the default run level (the input method of the kernel command line is related to the way you start the system).
Sometimes, it is necessary to start in a single user mode, so that the user can manually run FSCK before loading the partition, or at least before being loaded into the dispersed / usr partition, can manually run FSCK (on the dispersed file system, any activity It may make it more dispersed, so fsck should be run as much as possible). If the automated FSCK fails at startup, the running script init will automatically enter the single user mode. This is to prevent the system from using a non-coherent file system, this file system is F S C K cannot be automatically repaired. The phenomenon of non-coherent file system is extremely rare, and it usually causes unconstabilistic or experimental kernels of the hard disk, but it is best to prevent it.
Due to security considerations, in single user mode, the configured system is required to provide the user to provide the root password before starting the housing script. Otherwise, it will simply enter the right line of code for LILO, log in as root (of course, if the / etc / passwd has not been suitable for the problem of the file system, it is not suitable for this principle, to deal with this Situation, you'd better prepare a label on time).
Different runners have different uses, and should be set according to their own different situations.
For example, if the root password is lost, you can get the machine to start entering the single user status. Enter the LILO prompt after startup:
INIT = / bin / sh rw enables the machine to enter the run level, and hang the root file system is read or written. He will skip all system certifications, allowing you to use the Passwd program to change the root password, then start to a new run level.
The configuration of the running level is in / etc / inittab, as shown below:
12: 2: Wait: / etc / init.d / rc 2
The first field is an arbitrary specified label;
The second field indicates that this line is suitable for running that level (here 2);
When the third field indicates when entering the run level, init should run commands within the fourth field, and init should wait for the command to end. The /etc/init.d/rc command runs the startup and termination input to enter any of the commands required to enter the run level 2.
The command in the fourth field performs everything "mixed" when setting the run level. It starts a service that has not been run, and the service should not be run in the new run level. Depending on the version of the Linux version, the specific commands employed are different, and the configuration of the run level is also different.
When INIT starts, it will find a line of code in / etc / inittab, which specifies the default run level:
ID: 2: INitDefault:
You can ask init to enter a non-default run level when starting, which is achieved by specifying a "single" or "Emergency" command line parameter for the kernel. For example, the specification of the kernel command line parameters can be executed by LILO. In this way, you can choose a single user mode (ie the run level 1).
When the system is running, the Telinit command changes the run level. When the run level changes, init will run the corresponding command from the / etc / inittab.
Fourth, special configuration in / etc / inittab
In / etc / inittab, there are several special features that allow init to reactivate special events. These special features are marked with a special keyword in the third field. such as:
Powerwait
When INIT is turned off when the power is cut off, the system is turned off. Its premise is that the software with u p s and monitors U P S and notifies the INIT power supply has been cut.
2. Ctrlaltdel
Allow init to restart the system when the user presses the C T R L A L T D E L in the console keyboard. Note that if the system is placed in a public place, the system administrator can configure the C T R L A L T D E l to configure other behavior, such as ignore, etc. 3. Sysinit
The system is ready to run when the system starts. For example, this command will clear / TMP.
The special keywords listed above are incomplete. Other keywords and usage details, you can refer to your inittab man page.
5. Guide in single user mode
An important run level is single user mode (running level 1), in which only one system administrator uses a specific machine and runs system services as little as possible, which contains login. Single user mode is necessary for minority management tasks (such as running fsck on / usr partition), as this requires uninstall partition, but it is impossible unless all service systems have been killed.
A running system can enter a single user mode, and the specific practice is to use init, request the run level 1. When the kernel is started, you can enter the run level 1 when the kernel command line specifies the SINGLE or EMERGENCY keyword. The kernel is also specified for the command line for the init, and initiates from the keyword you should not use the default run level (the input method of the kernel command line is related to the way you start the system).
Sometimes, it is necessary to start in a single user mode, so that the user can manually run FSCK before loading the partition, or at least before being loaded into the dispersed / usr partition, can manually run FSCK (on the dispersed file system, any activity It may make it more dispersed, so fsck should be run as much as possible).
If the automated FSCK fails at startup, the running script init will automatically enter the single user mode. This is to prevent the system from using a non-coherent file system, this file system is F S C K cannot be automatically repaired. The phenomenon of non-coherent file system is extremely rare, and it usually causes unconstabilistic or experimental kernels of the hard disk, but it is best to prevent it.
Due to security considerations, in single user mode, the configured system is required to provide the user to provide the root password before starting the housing script. Otherwise, it will simply enter the right line of code for LILO, log in as root (of course, if the / etc / passwd has not been suitable for the problem of the file system, it is not suitable for this principle, to deal with this Situation, you'd better prepare a label on time).
Different runners have different uses, and should be set according to their own different situations.
For example, if the root password is lost, you can get the machine to start entering the single user status. Enter the LILO prompt after startup:
INIT = / bin / sh rw enables the machine to enter the run level, and hang the root file system is read or written. He will skip all system certifications, allowing you to use the Passwd program to change the root password, then start to a new run level.