What exactly did the Linux command line do from pressing power to the screen--linux mingetty command

Source: Internet
Author: User

Part I: Booting the kernel (in-core booting)
Part II: Running INIT and system initialization
The init program needs to read the configuration file/etc/inittab. Inittab is a non-executable text file that consists of several lines of instructions.
This file determines the boot level (1,2,3,4,5) of the system.
  
Inittab has such a line si::sysinit:/etc/rc.d/rc.sysinit ( call execution/etc/rc.d/rc.sysinit, there are many small functions in this script).

Part III: Start the daemon for the corresponding runlevel
After Rc.sysinit executes, it will return to Init to continue with other actions, usually followed by the/ETC/RC.D/RC program.
Execute the appropriate script RCX.D based on the startup level:
L0:0:WAIT:/ETC/RC.D/RC 0
L1:1:WAIT:/ETC/RC.D/RC 1
L2:2:WAIT:/ETC/RC.D/RC 2
L3:3:WAIT:/ETC/RC.D/RC 3
L4:4:WAIT:/ETC/RC.D/RC 4

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. You can switch between the 6 terminals by pressing ALT+FN (n corresponds to 1-6). 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 way to run the Mingetty program (in fact Mingetty can also adjust the login program to achieve the landing interface, see below ), Mingetty program can open the terminal, Set the 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.

下面来分析mingetty如何实现登陆界面附部分源码
    //autologin Automatic Login    if(Autologin) {Do_prompt (0);//        printf("Login:%s (automatic login) \ n", autologin);    LogName = Autologin; }Else//Otherwise call Get_logname () to get the user name, Get_logname will do_prompt () prompt input login:get_logname no source code elsewhere         while((logname = Get_logname ()) = =0)/* Do nothing * /;··//Omit part of source codeexecl (Loginprog, Loginprog, autologin?)"-F":"--", logname, NULL);/* Replace login program here to implement authentication user name password Note: global variable static char *loginprog = "/bin/login"; */Static voidDo_prompt (intShowlogin) {FILE *fd;intCif(Nonewline = =0)Putchar(' \ n ');if(Noissue = =0&& (fd = fopen ("/etc/issue","R"))) { while((c = getc (FD))! = EOF) {if(c = =' \ \ ') Output_special_char (GETC (FD));Else                Putchar(c);    } fclose (FD); }if(Loginpause) {puts("[Press ENTER to login]");    GETC (stdin); }if(Nohostname = =0)printf('%s ', HN);if(Showlogin)//autologin==0, skip.        printf("Login:"); Fflush (stdout);}
**验证成功后会执行/etc/profile(如果存在)文件完成相关环境初始化**例:终端输入 :mingetty将提示入户输入程序(以login为例),调用login程序,login验证通过后将执行配置文件/etc/profile(如果存在)

The entire start-up process is over.
Reference: http://www.51ou.com/browse/linuxml/mingetty.html

What exactly did the Linux command line do from pressing power to the screen--linux mingetty command

Related Article

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.