Linux Learning-linux system startup process

Source: Internet
Author: User

Linux system Boot Process

The boot process for Linux is not as complex as you might think, and the process can be divided into 5 phases:

    • Boot of the kernel.
    • Run init.
    • System initialization.
    • Set up the terminal.
    • The user logs on to the system.
Kernel boot

After power on, the first is the BIOS internal check, according to the BIOS set up the boot device (usually a hard disk) to boot.

After the operating system takes over the hardware, the kernel files in the/boot directory are read first.

Run init

The init process is the starting point for all processes, and you can compare it to the ancestor of all processes in the system, without which any process in the system will not start.

The INIT program first needs to read the configuration file/etc/inittab.

Run Level

Many programs need to boot up, under Windows system called ' Service ' (server), under Linux called ' Daemon ' (daemon).

One of the major tasks of the Init process is to run the startup program and assign the required system resources to it. Depending on the occasion, the action required to assign a different boot-start program is called a "runlevel" (runlevel).

At startup, different programs run according to the run level.

Linux systems have 7 classes of RunLevel

Run Level 0: System shutdown status, the system default RunLevel cannot be set to 0, otherwise it will not start the run Level 1: Single user working status, root privileges, for system maintenance, prohibit remote login run Level 2: Multi-User State (no NFS) RunLevel 3: Full multiuser State (with NFS), Login to console command line mode run Level 4: The system is not used, keep the RunLevel 5:x11 console, log in to the GUI mode run Level 6: The system shuts down and restarts, the default runlevel cannot be set to 6, otherwise it will not start normally

System initialization

There is a line in the init configuration file: Si::sysinit:/etc/rc.d/rc.sysinit It calls execution/etc/rc.d/rc.sysinit, and Rc.sysinit is a bash shell script,        It is mainly to do some system initialization work, Rc.sysinit is each run level must first run the important script. Its main tasks are: Activating the swap partition, checking the disk, loading the hardware modules, and some other priorities that need to be performed.

Which daemons will be run at each run level, and the user can be set from the row by using "System Services" in Chkconfig or Setup.

Set up terminal

After the RC finishes executing, return to init. At this point the system boot environment has been configured.

NIT Next opens 6 terminals so that the user can log on to the system. The following 6 lines in Inittab define 6 terminals:

1:2345:respawn:/sbin/mingetty tty12:2345:respawn:/sbin/mingetty tty23:2345:respawn:/sbin/  Mingetty tty34:2345:respawn:/sbin/mingetty tty45:2345:respawn:/sbin/mingetty tty56:2,345: Respawn:/sbin/mingetty Tty6

User Login System

In general, there are three ways users log in:

    • (1) Command line login
    • (2) SSH login
    • (3) Graphical interface login
Graphical interface and command line mode switching

Linux presets provide six command window terminals let's log in.

By default we are logged in the first window, that is, Tty1, the six windows are Tty1,tty2 ... tty6, you can press CTRL + ALT + F1 ~ F6 to toggle them.

If you have a graphical interface installed, by default it is entered into the graphical interface, you can press CTRL + ALT + F1 ~ F6 to enter one of the command window interfaces.

When you go to the Command window interface and then return to the graphical interface just press CTRL + ALT + F7 to come back.

If you are using a VMware virtual machine, the shortcut keys for the command window switch are ALT + Space + f1~f6. If you are in the graphical interface, press ALT + Shift + Ctrl + F1~F6 to switch to the command window.

Linux shutdown

Most of the Linux domain is used on the server, and there are few shutdown operations. After all, running a service on the server is endless, unless in exceptional circumstances, the last resort will be turned off.

The correct shutdown process is: sysnc > Shutdown > Reboot > Halt

The shutdown instruction is: shutdown, you can look at the help document with man shutdown. (In the Linux field, man will reap a lot of gains)

For example, you can run the following command to shut down:

Ten ' This server would shutdown after20:25+10+10 system 10 minutes after reboot reboot is reset, equivalent to Shutdown–r now Halt shutdown system, equivalent to Shutdown–h now and Poweroff

In conclusion, whether it is rebooting the system or shutting down the system, first run the sync command to write the data in memory to disk.

The command to shut down has shutdown–h now halt Poweroff and Init 0, and the command to restart the system has shutdown–r now reboot init 6.

Reference: https://code.ziqiangxuetang.com/linux/linux-system-boot.html

Linux Learning-linux system startup process

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.