[Operation level]
Linux has 7 runlevels)
Running level 0: The system is down. The default running level cannot be set to 0. Otherwise, the system cannot start normally.
Running Level 1: single-user working status, root permission, used for system maintenance, remote login prohibited
Running Level 2: multi-user status (no NFS)
Running Level 3: full multi-user status (with NFS). log on to the console and go to the command line mode.
Operation Level 4: The system is not used and retained
Running Level 5: X11 console. log on to the GUI
Running level 6: The system is shut down and restarted normally. The default running level cannot be set to 6. Otherwise, the system cannot start normally.
Running principle:
1. There are many server script programs in the/etc/rc. d/init. d directory, which are generally called services)
2. Under/etc/rc. d, there are 7 directories named rcN. D, corresponding to 7 running LEVELS OF THE SYSTEM
3. RcN. the d directory contains some symbolic link files that all point to init. the service script file under the d directory. The naming rule is K + nn + service name or S + nn + service name. The NN is a double digit.
4. The system will enter the corresponding rcN. d directory based on the specified running level, and retrieve the linked files under the directory in the order of file names
For Files starting with K, the system terminates the corresponding service.
For Files starting with S, the system starts the corresponding service
5. Run: runlevel or who-R.
6. For other running levels, use init n.
7. In addition, init0 indicates shutdown, and init 6 indicates restarting the system.
Run-level Configuration:
The running-level configuration is performed in the/etc/inittab line, as shown below:
12: 2: Wait:/etc/init. d/RC 2
The fields are described as follows:
ID: runlevels: Action: Process
ID: it is a sequence number of any specified four characters, which must be unique in this file; use the old version of libc5 (lower 5.2.18 ) Or the sysvinit compiled by the. out library is limited to 2 characters. Note: Login processes such as Getty must make the ID field consistent with the TTY number. For example, tty1 requires id = 1. Many earlier login processes follow this rule.
Runlevels: indicates the level at which the row is applicable (here it is 2, there can be multiple, indicating that the row needs to be run at the corresponding running level ); in addition, the sysinit, boot, and bootwait processes ignore this setting value.
Action: indicates how to run the process field command when entering the corresponding runlevels. The common field values and explanations are in the appendix. In this example, wait indicates that you need to run the process once and wait for it to end.
Process: The specific command to be executed. In the example,/etc/init. d/RC commands start the processes/commands that should be run in runlevel 2 and terminate them when they exit the runlevel (except for the programs that are still running at runlevel .)
When the running level changes and the running program is not specified in the new running level, init will first send a sigterm signal to terminate and then sigkill.
The valid action values are as follows:
Respawn: indicates that init should monitor this process, even after which it should be restarted.
Wait: init should run the process once and wait until it is finished before proceeding to the next step.
Once: init needs to run this process once.
Boot: run as the system starts, so the runlevel value is invalid.
Bootwait: run as the system starts, and init should wait until it ends.
Off: it makes no sense.
Initdefault: the default running level after the system is started. As processes at the corresponding running level are activated, the process field specified by the system is meaningless. If this record does not exist in the inittab file, you can query the running level on the console when the system starts.
Sysinit: the command to be run when the system starts. For example, this command will clear/tmp. You can check the/etc/rc. d/rc. sysinit script to learn about the operations it is running.
Powerwait: Allows init to shut down the system when the power supply is disconnected. Of course, the premise is that u p S and monitoring u p S and notifying init that the power supply has been cut off. This option is not listed by default in RH Linux.
Powerfail: Same as powerwait, but init does not wait until the running process ends. This option is not listed by default in RH Linux.
Powerokwait: The operation that init performs when the power monitoring software reports "power recovery.
Powerfailnow: If the UPS power supply is about to run out, the init operation is different from powerwait/powerfail.
Ctrlaltdel: Allows init to restart the system when you press the c t r l + a l t + d e l key combination on the console keyboard. Note: If the system is deployed in a public place, the system administrator can configure the c t r l + a l t + d e l combination key as another action, such as ignore. I set it to print out a swearing sentence ^ o ^.
Kbrequest: monitors the actions taken when a specific keyboard combination key is pressed, which is not complete yet.
OnDemand: A process marked with an OnDemand runlevel will be executed whenever the specified OnDemand runlevel is called. however, no runlevel change will occur (OnDemand runlevels are 'A', 'B', and 'C'
Remedy:
If your machine enters such a state, the system cannot boot because of the damaged/etc/inittab, and cannot log on because of the damaged/etc/passwd, or simply forget the password. What should I do?
Method 1:
Enter Linux 1 at the Lilo boot prompt and boot enters the single-user mode. This is a status in which almost no services are loaded. You can run the repair command in the provided shell.
Method 2:
Enter:
Init =/bin/sh RW
This allows the machine to enter runtime Level 1 and mount the root file system to read/write. He will skip all system authentication,
Let you use the passwd Program
To change the root password, and then start to a new running level.
Differences between the two methods:
(The single user mode is different from the input init =/bin/sh.
In single-user mode, RC. sysinit Initialization is the most basic initialization of the system, such as checking the file system, enabling swap, and Loading modules.
But the input init =/bin/sh will not be initialized, just give you a shell .)
[START process]
1. the system core searches for init in several places and starts executing the first detected init. (Inittab)
2. Run/etc/rc. d/rc. sysinit by init.
3. Rc. sysinit executes a series of operations and then runs RC. Serial (if any)
4. Run all scripts at the default running level by init.
5. Run RC. Local in init.
Linux boot explanation: http://jingyan.baidu.com/article/d2b1d1024a20f45c7e37d4fa.html