What are the stages of the Linux system startup process?

王林
Release: 2023-05-18 15:29:42
forward
1843 people have browsed it

Five stages of the system startup process: 1. Kernel boot stage; when the computer is turned on, the first is the BIOS power-on self-test. According to the startup device (usually the hard disk) set in the BIOS ) to start. During the system startup phase, the init process runs as the starting point for all processes. Without this process, no process in the system can start. 3. System initialization phase; call rc to complete some system initialization work. 4. Establish the terminal stage. 5. User logs into the system.

Linux system startup process

The startup process of the Linux system is not as complicated as everyone thinks. The process can be divided into 5 stages:

(1) Kernel boot.

(2) Run init.

(3) System initialization.

(4) Create a terminal.

(5) User logs in to the system.

1. Kernel boot

After the computer is turned on, it will first perform a BIOS power-on self-test, and then proceed according to the preset boot device (usually a hard disk) in the BIOS. to start. When the operating system takes control of the hardware, its first task is to load the core files in the /boot directory.

What are the stages of the Linux system startup process?

2. Run init

(1) The init process is the starting point of all processes in the system. You can compare it to the system The ancestor of all processes, without this process, no process in the system will start. The init program needs to read the configuration file /etc/inittab first.

What are the stages of the Linux system startup process?

(2) Run level: Many programs need to be started at boot. They are called "services" in Windows and "daemons" in Linux.

A major task of the init process is to run these programs that are started at boot. On different occasions, specific programs need to be started. For example, when used as a server, Apache needs to be started, but when used as a desktop, it is not required.

Linux allows different boot programs to be allocated for different occasions, which is called "runlevel". In other words, the runlevel determines which programs need to be run at startup.

What are the stages of the Linux system startup process?

(3) The Linux system has 7 runlevels (runlevel):

  • Runlevel 0: System shutdown state, system The default run level cannot be set to 0, otherwise it will not start normally.

  • Run level 1: single-user working state, root authority, used for system maintenance, remote login is prohibited

  • Run level 2: Multi-user state (without NFS)

  • Run level 3: Complete multi-user state (with NFS), enter the console command line after logging in Mode

  • Run level 4: The system is not used, reserved

  • Run level 5: X11 console, enter the graphical GUI mode after logging in

  • Run level 6: The system shuts down and restarts normally. The default run level cannot be set to 6, otherwise it cannot start normally.

3. System Initialization

There is such a line in the init configuration file: si::sysinit:/etc/rc.d/rc.sysinit It calls and executes /etc/rc.d/rc.sysinit. rc.sysinit is a bash shell script, which mainly completes some system initialization work. rc.sysinit is an important script that must be run first at every run level.

The main tasks it completes are: activating the swap partition, checking the disk, loading hardware modules and other tasks that need to be performed first.

What are the stages of the Linux system startup process?

4. Establish a terminal:

After rc is executed, return to init. At this time, the basic system environment has been set up and various daemon processes have been started. init will then open 6 terminals so that users can log in to the system.

5. User login system:

3 types: command line login, ssh login, graphical interface login

What are the stages of the Linux system startup process?

Attachment: Linux shutdown

1. The correct shutdown process is: sync > shutdown > reboot > halt

2. The shutdown command is: shutdown, you can take a look at man shutdown Help documentation.

3. Example:

sync # 将数据由内存同步到硬盘中。

shutdown –h 10 ‘This server will shutdown after 10 mins’
#这个命令告诉大家,计算机将在10分钟后关机,并且会显示在登陆用户的当前屏幕中。

shutdown –h now # 立马关机
shutdown –h 20:25 # 系统会在今天20:25关机
shutdown –h +10 # 十分钟后关机
shutdown –r now #系统立马重启
shutdown –r +10 #系统十分钟后重启
reboot # 就是重启,等同于 shutdown –r now

halt # 关闭系统,等同于shutdown –h now 和 poweroff
Copy after login

4. Whether you restart the system or shut down the system, you must first run the sync command to write the data in the memory to the disk.

The commands for shutting down include shutdown –h now, halt, poweroff and init 0, and the commands for restarting the system include shutdown –r now, reboot and init 6.

5. Shutdown will schedule a time for the system to shut down. It can be used to stop, shut down, and restart the machine.

shutdown -p now # 关闭机器 shutdown -H now # 停止机器 shutdown -r 09:35 # 在 09:35am 重启机器
Copy after login

To cancel an upcoming shutdown, just enter the following command:

shutdown -c
Copy after login

使用 halt 命令能够让 CPU 停止运行,但仍然保持通电状态。你可以用它使系统处于低层维护状态。注意在有些情况会它会完全关闭系统。

# halt ### 停止机器 # halt -p ### 关闭机器、关闭电源 # halt --reboot ### 重启机器
Copy after login

  poweroff 会发送一个 ACPI 信号来通知系统关机。

# poweroff ### 关闭机器、关闭电源 # poweroff --halt ### 停止机器 # poweroff --reboot ### 重启机器
Copy after login

  reboot 命令 reboot 通知系统重启。

# reboot ### 重启机器 # reboot --halt ### 停止机器 # reboot -p ### 关闭机器
Copy after login

The above is the detailed content of What are the stages of the Linux system startup process?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!