Previous Table of Contents Next


Module 77
login

DESCRIPTION

The login command allows you to identify yourself to the UNIX operating system. The operating system executes login for each new user establishing a terminal session, i.e., trying to log in to the system. You may also execute login at your shell prompt to change to a new user name and/or environment.

The login command requires two valid inputs; the first is your user name, the second is your password. When logging into the system for the first time you will be prompted for both your user name and your password. If you use login to change to a new user name, you can provide the new user name as the first argument followed by environment variables. Login will then prompt for the new password.

COMMAND FORMAT

Following is the general format for the login command.

     login [ -d device ] [ user_name [ env_var ] ]

BSD (Berkeley)
login [ -p ] [ user_name ]

Options

The following options may be used to control how jobs functions.

-d device The device is taken as the path of the tty port login will connect to if possible.

BSD (Berkeley)
-p Causes all additional environment varaibles to be preserved. By default the preexisting environment variables are discarded.

Arguments

The following list describes the arguments that may be passed to the login command.

user_name A valid user's login (user) name.
env_vars Environment variables that will be passed to the shell upon a successful login. Variables are described in Module 99.

FURTHER DISCUSSION

If you do not type at least one lowercase character at the login prompt, login will assume your terminal only supports uppercase and will set the tty port settings to uppercase only.

Depending on the UNIX System and system administrator that you have, the login program may have additional restrictions. Some UNIX installations require a dial-up password for modem (telephone line) users. You must type a dial-up password and your personal password correctly to gain access to the system.

A time-out feature may be implemented which will disconnect you from the system if you do not log in successfully within a specified time, usually one minute. The disconnect may be based on a certain number of unsuccessful attempts to log in. If you fail to log in within 5 attempts, the system may disconnect you from the system. If the file /var/adm/loginlog exists, all failed login attempts are logged (SV only).

The environment is initialized to:

HOME=your_home_dir_from_passwd_file
LOGNAME=your_login_name_from_passwd_file
PATH=/usr/bin
SHELL=your_login_shell_from_passwd_file
MAIL=/var/mail/your_login_name_from_passwd_file
TZ=timezone_specification

You can modify the environment by specifying arguments on the login command line or by adding them after your login name when login prompts you for it. The arguments can be in the form AAA or AAA=VVV. Arguments without an equal sign are placed in the environment as

     Ln=VVV

where n is an incremented number starting at 0 for each new variable added to the environment. If the argument contains an equal sign(=) it is placed in the environment unchanged.

If the variable already exists in the environment, the new value overwrites it. The PATH and SHELL environment variables cannot be changed. This prevents restricted shell users from spawning secondary login shells without restrictions.

The backslash(\) character can be used to quote the meaning of characters to login. For example, my\ name would allow a space in the login name.

DIAGNOSTICS AND BUGS

The login command may return one of the following messages if it encounters a problem.

login incorrect If the user name or the password cannot be matched.
no shell No shell (command interpreter) was found that login could execute based on the entry in the /etc/passwd file (field 7). Contact your system administrator.
cannot open password file The /etc/passwd file is not readable or does not exist. Contact your system administrator.
no directory No directory was found for your login based on the entry in the /etc/passwd file. Contact your system administrator. Some systems may allow you to log in with / being your HOME directory. It is highly advisable to log out and contact your system administrator.
no utmp entry The system requires that you exec login from your initial login shell instead of just using login.

RELATED COMMANDS

Refer to the modules 127, 72, 41, and 100 describing su, ksh, env and passwd, respectively.

RELATED FILES

The following is a list of files login uses.

/var/mail/user-name Mailbox file used to store mail for your user name.
/var/adm/utmp Used to store accounting information.
/var/adm/wtmp Used to store accounting information.
/var/adm/loginlog Used to log failed logins.
/dev/ttyXX Writes output to specified tty device.
/etc/motd The message of the day file, displayed during login.
/etc/passwd The system password file.
/etc/profile System profile, read by login sh/ksh to set up generic environment.
/etc/login System login configuration file, read by csh at login.
.profile Your profile, read by sh/ksh to set up environment.
.login Your login cofiguration file, read by csh at login.
/var/*/*/* Path used on System V and some BSD systems.

BSD (Berkeley)
/usr/spool/mail/user-name Mailbox file used to store mail for your user name.
/etc/utmp Used to store accounting information.
/etc/wtmp Used to store accounting information.

APPLICATION

The login command is used by the UNIX operating system to control access to the system. It can be used by users already logged on to log in again with a new user name and new environment.

TYPICAL OPERATION

In this activity you use the login command to log in to the UNIX System. Locate a terminal that is connected to the UNIX System you wish to use.

1.  Type mylogin after the login prompt and press Return.
     Your_System_Name login: mylogin

NOTE:  
The # (Del-BSD) key must be used for backspacing and the @ (^U-BSD) key must be used to kill a line of input. You may have to press the "break," "interrupt," or "attention" key so UNIX will recognize your terminal is trying to communicate and at what baud rate. Some systems require you to press Return before the login prompt is displayed.



2.  Notice the system responded with a passwd: prompt. Type imauser2 (your passwd) and press Return after the prompt.

NOTE:  
The password on UNIX System V must be at least six characters long and contain one alpha and one numeric.



3.  If you entered the correct user name and password, UNIX logs you into the system. If you entered an incorrect user name or password, re-enter your user name and password as illustrated below.
     Your_System_Name login: mylogin
     passwd:
     login incorrect
     login: mylogin
     passwd: &at; If you are not successful after several attempts, contact your system
     administrator for assistance.
4.  Turn to Module 127 to continue the learning sequence.


Previous Table of Contents Next