Login and Logout

Source: Internet
Author: User

Inux Login and logout details               login is the first process you face when working with a Linux system, This is correct for using the terminal and for using Linux over the network. But the login process itself is not what you see on the terminal, what you see is actually Getty (Get Teletype terminal, early on the computer meant to get the tape terminal, now can be directly understood as open terminal), it is by the Init (through/etc/ Inittab) is added while starting the login process.             So the complete start-up chain is: Shell-and Applicatio, passwd, Login, Getty, Init Ns. This is technically true when the real implementation is still a little different, for example, sometimes login and passwd is in a program, but the above this chain is typical of UNIX.          So why are we doing this? Why not write a program to handle all the work. Is it bad to have a Getty program handle login and passwd at the same time?         Let a program do just one simple thing and then link many simple tasks to create this complex operating environment, which is the key to securing UNIX stability, and this is a key design guideline when you create your system. (See KISS Guidelines, Classic in Unix)           DEBIAN6 on six terminals (Ctrl+alt+f1~f6 because F7,F8 is used to open the graphical interface instead of being used as a terminal) , but actually the kernel defaults to 64 terminals, so where are the other terminals? If you are on a Linux virtual machine, you can access Tty10 even tty12 (using ctrl+alt+f*), but you do not have more function keys, and later we are discussing how to access other terminals.  logout process          logout process is simple, he needs to terminate the login process open task or shell. Notice that it's shutting down not just a shell, but all things. If I use long as a user login I will getA shell, if I use LS, I will get the result of LS and then I logout. So logout's shell sends a signal to the parent process to notify it that the shell has been terminated. But when the shell's parent process is login and login is stopped (logout terminal login and Shell), who gets the return value of the shell? Is init to accept the return value of logout, after shutting down Getty, Login, Logout, and so on, Init re-opens a Getty to wait for input. Let's take a look at the fun stuff:                         -rwxr-xr-x 1 root R Oot 975488 Dec  2012/bin/bash                         -rwxr-xr-x 1 root root  49008 may  2012/bin/login              &NB Sp          -rwxr-xr-x 2 root root  32040 Dec  2012/sbin/getty      &N Bsp                  -rwsr-xr-x 1 root root  51096 may  2012/usr/b IN/PASSWD we can all see, in addition to passwd others have Rwxr-xr-x permissions, all of them can be executed by any user, and passwd is-rwsr-xr-x permission, this s is setuid flag, This bit is a program or command that allows a normal user to run a root account in the root user's role, so passwd is run under root (even if it is aUse by an ordinary user). With this, we can reduce the security risk.   login configuration you log in using login, you not only open a shell but also configure your runtime environment (runtime env), this configuration if in/etc is a system-level configuration, if in your personal home directory is a personal configuration. The approximate division is such a: /etc/profile-For all users and all shells/ETC/BASH.BASHRC-bash configuration for all users~/.BASHRC-Your personal bash configurationSo in actual use we need to put the configuration in different configuration files according to the different requirements.  For example, a configuration is useful for all users who use the system, and we need to put it under/etc/profile. Su refers to the user login, here is the root permission, using the SU command (SU-) you not only switch user permissions and you create a new login session, so you get not only a root, but also a new runtime environment, which is very sensitive to security issues, Therefore, it is important to note that root permissions are used.  Of course, you can also use sudo to allow their users to temporarily get root permissions, which is a good way for desktop users, but for the larger system, to the user sudo permissions must pay attention, it is best not to give! Exit vs Logout Use Login login system, then exit the system we can choose Exit or logout, then there is a difference between the two? For most systems there is no difference between the two, but there is a little difference between the two: Logout will execute ~/.bash_logout (if any) when exiting, and exit will only quit work without performing ~/.bash_logout. There is no other difference.

Login and Logout

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.