Linux terminal and Terminal login process Introduction __linux
Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
Linux terminal and Terminal login process Introduction
The shell is the system's user interface, which provides the interface that the user interacts with the kernel. It receives the command entered by the user and sends it to the kernel for execution, and then displays the results to the user.
Linux Terminal usage Basics:
Monitors and keyboards are called terminals because they can control the system, which is called the console (physical console). If the software is used in a computer to achieve a number of non-interference, independent work of the console interface, is to implement a number of virtual consoles. Users log in as text, the user through the keyboard input command, through the Linux terminal to control the system. Typically, Linux starts with 6 virtual terminals (TTY1~6) by default. If the startup mode chooses to start X window directly, then X window is on the 7th virtual terminal.
Assuming that the user is now in the graphical interface, the selection of the Virtual Console can be achieved by pressing the Ctrl+alt key and the function key fn (n=1~6). For example, when a user logs in and presses the CTRL+ALT+F2 key combination, the user can see the "Login:" prompt, which is the second Virtual Console. If you press the ALT+F1 key at this point, you can go back to the first Virtual Console.
The Virtual Console makes Linux a real multi-user operating system. On different consoles, you can accept multiple user logins at the same time, and allow a user to log on multiple times. The user can switch to another Virtual Console to start another job while the work on one virtual Console is not finished.
Press the ALT+CTRL+FN key combination (N=1~6) in the X Window graphical interface to enter the console character operator interface. This means that the user can have X window and 6 console operation interface at the same time, press ALT+CTRL+F7 key combination in the console operation interface to return to the X Window graphics operation interface just now. In other words, using ALT+CTRL+FN key combination can realize the character interface and X Window interface fast switch.
Introduction to Linux Terminal Login: 1. When the system starts, the kernel creates a process ID of 1, which is the init process, and the INIT process makes the system go into multiuser state. The init process determines which terminals need to be opened according to the profile/etc/inittab, and for each terminal device that is allowed to log on, Init invokes a fork, and the child process it generates executes the Getty (EXEC) program. (Different operating system configuration files may be different)
2.getty calls the Open function for the terminal device to open the terminal in read-write mode. Then getty the output "Longin:" and waits for the user to type the user name.
3. When the user type the user name, the Getty work completes. Then call the login program: execle ("/bin/login", "Login", "P", username, (char *) 0,ENVP)
4. Password verification is correct, login will switch directories to the user's home directory, change the authority of the terminal device, login process changed to login user ID and invoke user login shell:execl ("/bin/sh", "-sh", (char *) 0)
5. Login Shell to read its startup files (Bourne shell) and Korn shell.
From Getty start Exec to login, and then exec to bash, in fact, are the same process, so the control terminal has not changed, file descriptors 0, 1, 2 still point to the control terminal. Because fork will copy the PCB information, so are other processes initiated by the shell.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.