Details of CentOS operation level and startup process

Time:2019-11-7

1. Linux operation level:

1) 0: shutdown

2) 1: single user

3) 2: no network service in multi-user state

4) 3: network service in multi-user state

5) 4: system is not used and reserved for users

6) 5: graphic interface

7) 6: system restart

Note: the commonly used run levels are 3 and 5. To modify the run level, you can change the number in the ID: 5: initdefault of the file / etc / inittab.

2. Solutions to forget root password:

When the machine starts and enters the grub boot program, press e, and then select the line with label = (generally the second line), then click an e, enter a 1 (i.e. the operation level is changed to 1), and then enter enter the stand-alone mode, and then restart to modify the original configuration file.

3. Linux boot process:

1) load BIOS. When you turn on the computer power, the computer will first load BIOS information, which includes CPU related information, device startup sequence information, hard disk information, memory information, PNP characteristics, etc. So the computer knows which hardware device to read.

2) read the MBR. As we all know, the first sector of track 0 of the disk is called the MBR (master boot record), that is, the master boot record. Its size is 512 bytes, with pre boot information and partition table information. When the system finds the hard disk MBR specified by BIOS, it will copy it to the physical memory where the 0x7c00 address is located. The content of memory is boot loader, and specific to your computer, that is Lilo or grub.

3) boot loader: a small program before the operating system kernel runs. Usually this small program, we can initialize the hardware device, establish the map of memory space, so as to bring the software and hardware environment of the system to a suitable state, so as to make all preparations for the final call to the operating system kernel. There are several types of boot loaders, among which grub, lilo and spfdisk are the most commonly used. For example, grub, the system will read the grub configuration information in memory (usually menu.lst, or grub. LST), and start different operating systems according to this configuration information.

4) load kernel: according to the path of the kernel image set by grub, the system reads the memory image and decompresses it. At this time, the screen will generally output the prompt of “uncompressing Linux”. When the decompression of the kernel is completed, the screen outputs “OK, booting the kernel”. The system places the decompressed kernel in memory and calls the star_kernel() function to start a series of initialization functions, initialize various devices and complete the establishment of Linux core environment. At this point, the Linux kernel has been established, and Linux based programs should be able to run normally.

5) user level init sets the running level according to the inittab file: after the kernel is loaded, the first running program is / SBIN / init, which will read the / etc / inittab file and initialize according to the file. In fact, the most important function of the / init / inittab file is to set the running level of Linux in the form of “: ID: 5: initdefault:”, which indicates that Linux needs to run at level 5. See 1 for operation level.

6) execute rc.sysinit for init process: after setting the running level, the first user layer file executed by Linux system is / etc / rc.d/rc.sysinit script program, which does a lot of work, including setting path, setting network configuration (/ etc / sysconfig / network), starting swap partition, setting / proc, etc.

7) start the kernel module: load the kernel module according to the file / etc / modules.conf or the file in the directory / etc / modules. D.

8) execute script programs of different operation levels: according to different operation scopes, the system runs corresponding script programs from rc0. D to RC6. D to complete corresponding initialization and start corresponding services.

9) executing / etc / rc.d/rc.local: rc.local is where Linux leaves the user to personalize after all initialization work. You can put what you want to set up and start up here.

10) execute the / bin / login program and enter the login status: at this time, the system has entered the time to wait for the user to enter username and password, and you can login to the system with your own account.