Detailed explanation of CentOS running-level init

Source: Internet
Author: User

This article describes in detail the roles of different running levels in startup. Linux seems to be a monster for advanced users on the DOS/Win9x/NT platform. No config. sys, no autoexec. bat, and machine configurations with personal characteristics do not know where to start. It should be noted that many people think that Linux is a clone of Unix, but this statement is unfair to Linux. Linux is more open and powerful than Unix. We should call it GNU/Linux.

When Linux is started, it runs a program called init and starts subsequent tasks, including multi-user environments and networks. So what is the runtime level? Simply put, the running level is the function level currently running in the operating system. This level ranges from 1 to 6 and has different functions. These levels are specified in the/etc/inittab file. This file is the main file found by the init program. The first service to run is the files stored in the/etc/rc. d directory. In most Linux releases, the startup script is located at/etc/rc. d/init. d. These scripts are connected to the/etc/rc. d/rcn. d directory by ln command (here n is the running level 0-6 ). For example:

The S10network under/etc/rc. d/rc2.d is connected to the network script under/etc/rc. d/init. d.
Therefore, we can know that the files under rc2.d are related to Operation Level 2.
"S" at the beginning of the file indicates that "start" indicates that the service is started, and "10" indicates the order in which the service is started. For example, in the same directory, you can also see the S80postfix file. The order of 80 is after 10, because if the network is not started, starting postfix does not work. Check/etc/rc. d/rc3.d again. You can see the file S60nfslock, but this file does not exist in the/etc/rc. d/rc2.d directory. NFS uses this file, which is generally used in multi-user environments, so it is stored in the rc3.d directory. In addition, you can see files starting with K in/etc/rc. d/rc2.d, for example
/Etc/rc. d/rc2.d/K45named, K indicates kill
The standard Linux operating level is 3 or 5. If it is 3, the system is in the multi-user State. If it is 5, the X Window System is running. If it is currently 3 or 5, and you reduce the running level to 2, init will execute the K45named script.

So what is the operating level of linux?
Simply put, the running level is the function level currently running in the operating system. This level ranges from 0 to 6 and has different functions. These levels are specified in the/etc/inittab file. This file is the main file found by the init program. The first service to run is the files stored in the/etc/rc. d directory. Different running levels are defined as follows: (refer to/etc/inittab in CentOS)

# The default running level is as follows:
Reference #0-stop (do not set initdefault to 0)
#1-single-user mode
#2-multiple users, but no NFS
#3-full multi-user mode
#4-useless
#5-X11
#6-Restart (do not set initdefault to 6)

Detailed explanation of each running level:
If 0 is referenced, the instance is shut down.
1 is the single-user mode, just like the security mode in Win9x.
2: multi-user mode, but not supported by NFS.
3 is a complete multi-user mode, which is a standard operation level.
4. Generally, you can use it to do things in some special cases. For example, you can switch to this mode to make some settings when the battery of your laptop is exhausted.
5 is X11, And it enters the X Window System.
6. Restart the init 6 host.

Different running levels have different functions and should be set according to different situations. For example, if we lose the root password, we can set it in single-user mode for machine startup. 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, so that you can use the passwd program to change the root password, and then start to a new running level.

Of course, at the lilo prompt, you can enter linux single in boot to enter the single user status. However, the single user mode is different from the init =/bin/sh input.
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.
The input init =/bin/sh does not initiate any initialization, but just gives you a shell.


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.