Linux system Start-up process

Source: Internet
Author: User

Read Catalogue

    • Linux System Boot Process
    • Boot of the kernel
    • Run Init
    • Run level
    • System initialization
    • Set up terminal
    • User Login System
    • Switch between image mode and text mode
    • Linux shutdown

When we start the Linux operating system, it will show the hardware self-test and a lot of boot information, including start failure we are all at a glance!

  1. In the CentOS 5.x version, you can fully see the hardware self-test and boot information
  2. Only the progress bar is displayed on the CentOS 6.x version, just press F4

Or

  • Root user modifies/boot/grub/grub.conf file
  • Vim/boot/grub/grub.conf
  • Remove "RHGB" and "quiet", Save
  • Reboot the system to
Linux system Boot Process
    • The startup process of a Linux system is not complicated, and its process can be divided into 5 stages.
    1. Boot of the kernel
    2. Run Init
    3. System initialization
    4. Set up terminal
    5. User Login System
boot of the kernel
    • When the computer power is turned on, the first is the BIOS post, according to the boot device set in the BIOS (usually the hard disk) to boot
    • When the hard disk is read to the system, the operating system takes over the hardware and then reads the kernel file into the/boot directory.

Run init
    • The init process is the starting point for all processes in the system, and of course you can compare it to the ancestors of all processes in the system, without which no process in the system will start.
    • The INIT program first needs to read the configuration file/etc/inittab

Run Level
    1. Many programs need to boot up, they are called "service" in Windows, and Linux is called "daemon" (daemon)
    2. One of the major tasks of the Init process is to run these boot-up programs
    3. However, different applications need to start different programs, such as server, need to start Apache, FTP, DHCP and other network services, as a personal desktop environment does not need to start
    4. Linux allows different boot programs to be assigned for different occasions, which is called "RunLevel" (runlevel)! That is, at startup, depending on the runlevel, determine which programs to run

5. Linux system has 7 runlevel (runlevel)

    • RunLevel 0: System down state, system default RunLevel cannot be set to 0, otherwise it will not start normally
    • RunLevel 1: Single User working status, root privilege, for system maintenance, remote login Forbidden
    • RunLevel 2: Multi-User State (no NFS)
    • RunLevel 3: Full multiuser State (with NFS), enter console command line mode after login
    • Run Level 4: System not used, reserved
    • Run level 5:x11 console, login to GUI mode
    • RunLevel 6: The system shuts down gracefully and restarts, the default runlevel cannot be set to 6, otherwise it will not start normally
initialization of the system
    • 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 complete some system initialization work, Rc.sysinit is each run level must first run the important script
    • Its main work is to activate the swap partition, check the disk, load the hardware module, and some other priority tasks to perform
L5:5:WAIT:/ETC/RC.D/RC 5
    • This line indicates that running with the 5 parameter/ETC/RC.D/RC,/ETC/RC.D/RC is a shell script that accepts 5 as a parameter to execute all RC startup scripts under the/etc/rc.d/rc5.d/directory,/etc/rc.d/rc5.d/ These startup scripts in the directory are actually some connection files, not the actual RC startup scripts, and the actual RC startup scripts are actually placed in the/etc/rc.d/init.d/directory.
    • These RC startup scripts have similar usage, they generally accept start, stop, restart, status and other parameters
    • The RC startup script in/etc/rc.d/rc5.d/is usually a connection file that starts with K or S, and will run with the start parameter for startup scripts starting with S
    • If it is found that the corresponding script also has a K-link, and is already in the running state (the file under the/var/lock/subsys/as a flag), the stop is the first parameter to stop these started daemons, and then rerun
    • This is done to ensure that when Init changes the RunLevel, all associated daemons are restarted
    • As to which Daemons will be run at each run level, users can use the "System Services" in Chkconfig or Setup from the row settings

set up terminal
    • After the RC executes, return to INIT, the basic system environment has been set up, the various daemons have been started
    • Init then opens 6 terminals so that the user can log in to the system, and 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:2345:respawn:/sbin/mingetty Tty6
    • From the above can be seen in the 2, 3, 4, 5 of the operating level will be respawn mode to run Mingetty program, mingetty program can open terminal, set mode
    • At the same time it will display a text login interface, which is the login interface we often see, in this login screen will prompt the user to enter a user name, and the user input user will be passed as a parameter to the login program to verify the identity of the user
User Login System
    • In general, there are three ways for users to sign in
    1. Command line Login
    2. SSH Login
    3. Graphical interface Login

    • For graphical users with a run level of 5, their login is via a graphical login interface. After successful login, you can go directly to KDE, GNOME and other window manager.
    • This article is mainly about the text mode of login: When we see the Mingetty login interface, we can enter the user name and password to log into the system
    • Linux Account Verification Program is Login,login will receive mingetty from the user name parameters
    • Login will then parse the username: If the user name is not root and there is a/etc/nologin file, login will output the contents of the Nologin file and then exit
    • This is typically used for system maintenance to prevent non-root users from logging on. Only the terminal registered in/etc/securetty allows the root user to log in, and if the file does not exist, root can log on at any terminal
    • The/etc/usertty file is used to make additional access restrictions to the user, and there are no additional restrictions if the file does not exist
How to switch between graphic mode and text mode
    • 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 interface
    • When you go to the Command window interface and 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 forced shutdown
    • The correct shutdown process is: sysnc > Shutdown > Reboot > Halt
    • The Shutdown command is: shutdown
    • You can shut down the computer by running the following command
Sync synchronizes data from memory to hard disk shutdown shutdown instructions
    • You can see the help document with man shutdown
Shutdown–h ' This server would shutdown after ten mins ' This command tells you that the computer will shut down after 10 minutes and will be displayed in the current screen of the logged-on user shutdown–h now immediately shut down Shutdow N–h 20:25 The system will shut down at 20:25 shutdown–h +10 10 minutes after shutdown Shutdown–r now system immediately restarts Shutdown–r +10 system 10 minutes after restart reboot is reset, equivalent to Shutdown–r no Whalt shutdown system, equivalent to Shutdown–h now and Poweroff

To conclude, whether it's 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, the command to reboot the system has shutdown–r now reboot Init 6

Linux system Start-up 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.