.DF 1 HR 2 HO 3 HB .VS 1 "Logging in and out" "5/01/1989:1530" .sp 1i .T "Logging in and out" .sp .T "Martin Guy" .sp .T "\f2Tutorial Fellow\fP" .T "\f2University of Kent\fP" .T "\f2Canterbury\fP" .VS .T "Overview of the Login Sequence" .sp .5i .B init .C opens the terminal device .sp .B getty .C sets terminal modes and issues the first \f3login:\fP prompt .sp .B login .C performs user validation and sets up the user's environment .sp .B shell .C starts other programs running at the user's request .VS .T "login" .sp .5i .B Looks up the user's details in the password file .sp .B Validates the user's password .sp .B Makes a record of the login .sp .B Displays the message of the day (from \f3/etc/motd\fP) .sp .B Checks whether the user has mail .sp .B Sets up the user's environment .sp .B Executes their shell .VS .T "The Standard Environment" .sp .5i .A \f3login\fP needs to initialise: .B current directory .C the user's home directory .B User-ID and Group-ID of the process .C the users's UID and the GID for their group .B standard environment variables, e.g.: .C HOME:\ full pathname of their home directory .C USER:\ the user's login name .B umask (file creation mask) .C 022 (deny write permission to group and world) .A It gets much of this information from the user's entry in the password file .VS .T "The password file" .sp .5i .A The file \f3/etc/passwd\fP is read by \f3login\fP to find out about the user it is logging in. .A The file contains one line for each user who has an account on this machine. Each line consists of: .sp .B username .B encrypted password .B uid .B gid .B special (a.k.a. GECOS field) .B home directory .B shell .VS .T "Login records" .sp .5i .A \f3login\fP amends the following files: .B \f3/etc/utmp\fP .C who is logged in now .B \f3/usr/adm/wtmp\fP .C a list of what login sessions there have been today .A These are binary files, but their contents can be displayed with the \f3who\fP and \f3last\fP commands respectively. .A When the user logs out, the master \f3init\fP (process 1) notices this and .C clears the entry in \f3utmp\fP for that terminal line .C writes another record into \f3wtmp\fP to record the time of logout .VS .T "Special shells" .sp .5i .A Utility logins .B date .B who .A System logins .B uucp .A Restricted shells