Linux Server startup process

Source: Internet
Author: User

When Linux starts, we see a lot of startup information, but it's not as complicated as it was when Linux started, and its process is divided into five parts.

1. Boot of the kernel

When the computer is powered on, the first is the Blos post, starting with the boot device (usually the hard disk) set up in Blos.

After the operating system takes over the hardware, read the kernel file in the/boot directory first

2. Run Init

The init process is the starting point for all processes in the system, and you can compare her to the ancestors 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

Many programs need to boot up, they are called daemons in Linux (daemon)

One of the main tasks of the Init process is to run these boot-initiated programs.

But in different situations need to start different programs, modify the Init configuration file to confirm the start-up program

Linux Run level settings

Run Level 0: shutdown

Run Level 1: Single user mode

RunLevel 2: Multi-User State (no NFS)

Run Level 3: Command line interface

Run Level 4: System not used, reserved

Run Level 5: Graphical interface

Run Level 6: Restart

3. 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.

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 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 a similar usage, and they generally accept start, stop, restart, status, and so on.

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 you find that the corresponding script also has a K-link, and is already in the running state (the file under/var/lock/subsys/as the flag), the stop will be 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, the user can be set from the row by using "System Services" in Chkconfig or Setup.

4. Setting up the terminal

After the RC finishes executing, return to init. At this point the basic system environment has been set up, various daemons have been started.

Init then 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 tty1

2:2345:respawn:/sbin/mingetty Tty2

3:2345:respawn:/sbin/mingetty Tty3

4:2345:respawn:/sbin/mingetty Tty4

5:2345:respawn:/sbin/mingetty Tty5

6:2345:respawn:/sbin/mingetty Tty6

From the above can be seen in the 2, 3, 4, 5 of the operating level will be respawn to run the Mingetty program, mingetty program can open terminal, set mode.

5. User Login System

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.

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 then parses 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 on, 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.

Summarize:

Login Shell, user login, operating level, init process ,/boot

Whether restarting 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.


Linux Server 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.