学习的过程也是一个遗忘的过程,为了留下学习轨迹或者是为了以后能够回忆下学习的过程,我会时不时的来更新自己正在学习的内容。
linux System Startup and the Login Shell
上一篇 /
下一篇 2008-08-22 23:01:40
/ 个人分类:Linux & shell
When you start up your system, the first process is called init. Each process has a process identification number associated with it, called the PID. Because init is the first process, its PID is 1. The init process initializes the system and then starts another process to open terminal lines, and sets up the standard input (stdin), standard output (stdout), and standard error (stderr), which are all associated with the terminal. The standard input normally comes from the keyboard; the standard output and standard error go to the screen. At this point, a login prompt (Login:) appears at your console. After you type your login name, you are prompted for a password (you will be given up to 10 chances to enter the correct password). The /bin/login program then verifies your identity by checking the first field in the /etc/passwd file. If your username is there, the next step is to run the password you typed through an encryption program to determine if it is indeed the correct password. Once your password is verified, the login program sets up an initial environment consisting of variables that define the working environment that will be passed to the shell. The HOME, SHELL, USER, and LOGNAME variables are assigned values extracted from information in the /etc/passwd file. The HOME variable is assigned your home directory; the SHELL variable is assigned the name of the login shell, the last entry in the passwd file. The USER and/or LOGNAME variables are assigned your login name. A PATH variable to help the shell find commonly used utilities is located in specified directories. It is a colon separated list initially set to: /usr/local/bin:/bin:/usr/bin. When login has finished, it will execute the program found in the last entry of the /etc/passwd file. Normally, this program is a shell. If the last entry in the /etc/passwd file is /bin/tcsh or bin/csh, the TC shell program is executed. If the last entry in the /etc/passwd file is /bin/bash,/bin/sh, or is null, the Bourne Again shell starts up. If the last entry is /bin/pdksh, the Public Domain Korn shell is executed. This shell is called the login shell.
After the shell starts up, it checks for any systemwide initialization files and then checks your home directory to see if there are any shell-specific initialization files there. If any of these files exist, they are executed. The initialization files are used to further customize the user environment. After the commands in those files have been executed, a shell prompt appears on your console, unless a windowing program, such as X Windows or Gnome is launched, at which point a number of xterm or visual shell windows will appear. When you see the shell prompt, either at the console or in an xterm or other desktop window, the shell program is now waiting for your input
导入论坛
收藏
分享给好友
推荐到圈子
管理
举报
TAG: