


What are the stages of the Linux system startup process?
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.
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.
(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.
(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.
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
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:
<code>sync # 将数据由内存同步到硬盘中。<br/><br/>shutdown –h 10 ‘This server will shutdown after 10 mins’ <br/>#这个命令告诉大家,计算机将在10分钟后关机,并且会显示在登陆用户的当前屏幕中。<br/><br/>shutdown –h now # 立马关机<br/>shutdown –h 20:25 # 系统会在今天20:25关机<br/>shutdown –h +10 # 十分钟后关机<br/>shutdown –r now #系统立马重启<br/>shutdown –r +10 #系统十分钟后重启<br/>reboot # 就是重启,等同于 shutdown –r now<br/><br/>halt # 关闭系统,等同于shutdown –h now 和 poweroff<br/></code>
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 重启机器
To cancel an upcoming shutdown, just enter the following command:
shutdown -c
使用 halt 命令能够让 CPU 停止运行,但仍然保持通电状态。你可以用它使系统处于低层维护状态。注意在有些情况会它会完全关闭系统。
# halt ### 停止机器 # halt -p ### 关闭机器、关闭电源 # halt --reboot ### 重启机器
poweroff 会发送一个 ACPI 信号来通知系统关机。
# poweroff ### 关闭机器、关闭电源 # poweroff --halt ### 停止机器 # poweroff --reboot ### 重启机器
reboot 命令 reboot 通知系统重启。
# reboot ### 重启机器 # reboot --halt ### 停止机器 # reboot -p ### 关闭机器
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)
