login(1) login(1)
NAME
login - system login
SYNOPSIS
login [loginname [environment ...]]
DESCRIPTION
In the Korn shell the login command is a shell built-in. In the Bourne
shell /usr/bin/login is invoked.
login can be called by the user and by the system:
- When you first sign in on a terminal, login is invoked by the sys-
tem.
- If you wish to call login as a command in the Bourne shell, it must
replace the current login shell. This entails invoking the command
from the login shell in the form exec login, which terminates the
current shell when login is started. The fact that the process ID
does not change indicates that no new process is created.
login performs the following actions:
- it prompts for the password associated with the specified login
name.
- it makes the home directory the working directory. The login direc-
tory that is entered in the /etc/passwd file for the given login
name is assigned to the HOME variable.
- it initializes the standard shell variables to the appropriate
default values (see Functionality of the login command).
- it invokes the startup program that is assigned to the given login
name in the /etc/passwd file.
If the startup program assigned to the specified login name in the
/etc/passwd file is /usr/bin/sh, login is overlaid by a new login
shell which performs the following actions:
- it executes the file /etc/profile.
- it also executes the file $HOME/.profile if you have created one.
The shell environment defined for the given login name will thus be
valid from this point on. If you wish to retain your current shell
environment and directory when switching to another login name, you
should use the su(1) command instead of login.
If the line CONSOLE=terminal is defined in the /etc/default/login
file, the only terminal on which you can log in as root is the termi-
nal defined as the console.
Page 1 Reliant UNIX 5.44 Printed 11/98
login(1) login(1)
Before the call
The name you use to log in must appear in the /etc/passwd file. If it
does not, you should contact the system administrator.
If there are no lowercase letters in the first line of input pro-
cessed, login assumes that the terminal can only process uppercase
letters.
loginname
Login name under which you wish to log in. This name must appear
in the /etc/passwd file.
loginname not specified:
The login command will prompt you to enter the login name in the
next line.
If a password has been defined for this login name in the
/etc/shadow file, login will then prompt you to enter the pass-
word.
Your input will not be displayed on the screen or recorded in a
file.
environment
Arguments that can be specified in the form yyy or xxx=yyy to
assign a value to an environment variable. These arguments may be
supplied either at execution time or when you enter your login
name. xxx is the name of an environment variable; yyy is a value
to be assigned to an environment variable. Typing a backslash in
front of a character in yyy quotes that character, thus allowing
characters such as spaces and tabs to be included.
xxx=yyy Environment variable xxx is assigned the value yyy. If
the environment variable already has a value, it is
replaced by the new value, with two exceptions: the
variables PATH and SHELL cannot be changed in this way.
yyy The value yyy is assigned to the environment variable
Ln, where n is a number that starts at 0 and is incre-
mented each time a variable name is required (until all
yyy values have been assigned).
Page 2 Reliant UNIX 5.44 Printed 11/98
login(1) login(1)
Functionality of the login command
The login command compares the specified login name and password with
the corresponding entry in the /etc/passwd and /etc/shadow files. If
all entries are accurate, you will be logged into the system under the
given login name.
If invalid entries are made, the terminal line will be disconnected
after five unsuccessful login attempts. This will also occur if you do
not complete the login successfully within a defined period of time.
The following steps are performed sequentially after a successful
login:
- login searches the /etc/passwd file for the user ID (UID) and group
ID (GID) associated with the specified login name.
Login names are internally maintained by the operating system under
their user and group IDs only.
- login enters the login name in the /var/adm/utmp file. This file
contains information about all users currently logged in.
The /var/adm/utmp file is accessed by the who(1) command.
- If the /var/adm/wtmp file exists, login enters the login name in
it. This file is used to consecutively record all attempts to log
in and out.
- login displays the last time you logged in under this login name.
This information is obtained from the file /var/adm/lastlog.
- login assigns default values to the following environment vari-
ables:
Page 3 Reliant UNIX 5.44 Printed 11/98
login(1) login(1)
___________________________________________________________________
| Variable | Assignment: |
|__________|_______________________________________________________|
| HOME | Name of the login directory (from /etc/passwd) |
|__________|_______________________________________________________|
| LOGNAME | Login name (from /etc/passwd) |
|__________|_______________________________________________________|
| MAIL | /var/spool/mail/loginname |
|__________|_______________________________________________________|
| SHELL | /usr/bin/sh (from /etc/passwd) |
|__________|_______________________________________________________|
| TZ | defined timezone (from /etc/default/login or |
| | /etc/TIMEZONE) |
|__________|_______________________________________________________|
| PATH | defined search path (from /etc/default/login) |
|__________|_______________________________________________________|
| LANG | NLS variable for defining an internationalized envi- |
| | ronment |
|__________|_______________________________________________________|
| TTY | Terminal port number |
|__________|_______________________________________________________|
| TERM | Terminal type |
|__________|_______________________________________________________|
| USER | User's login name |
|__________|_______________________________________________________|
You will find more information on these environment variables in the
description of the sh command. Here you will also find out how to
change default values and define additional environment variables.
- login switches to the login directory that is entered in
/etc/passwd file for this login name.
- login invokes the program that is assigned to the given login name
in the /etc/passwd file. Typically, /usr/bin/sh is started as the
login shell [see sh(1)]. This shell overlays login.
If the program name /etc/passwd is given as *, the named login
directory becomes the root directory, thus making it the starting
point for path searches for file names that begin with a / (slash).
In addition, login is re-executed at the new root structure.
Page 4 Reliant UNIX 5.44 Printed 11/98
login(1) login(1)
Starting work at the terminal
When you initially turn on the terminal, the cursor appears on the
screen. The system then prompts you for a login name (on some termi-
nals you may have to press CTRL-D first) and passes your input to
login. login then prompts you for a password. (If you log in
incorrectly, login again prompts you for a login name.) This also
applies after you have terminated a session by pressing CTRL-D.
The following system processes must thus be active before you can
begin working at the terminal:
- /etc/init starts the system process getty for all connected termi-
nals. A new process is thus generated for each terminal.
- /etc/getty displays the welcome screen and overlays itself with
login after reading the login name.
After you have successfully logged in, login overlays itself with the
startup program entered in the /etc/passwd file. This is normally the
login shell /usr/bin/sh. If you terminate this login shell with
CTRL-D, you will terminate the current process, i.e. /etc/init res-
tarts the system process /etc/getty.
ERROR MESSAGES
Login incorrect
This error message can have the following causes:
- You have made a typing error when entering the login name or the
password. The login command prompts you to repeat your input.
- This login name has not yet been set up. Contact the system
administrator.
- The password has been changed. Contact the system administrator.
No shell
You have either no execute permission for the corresponding shell
under this login name, or the entry in the /etc/passwd file has not
been correctly made for this login name. Contact the system adminis-
trator.
unable to change directory to ""
The login directory for this login name has not been installed. Con-
tact the system administrator.
Page 5 Reliant UNIX 5.44 Printed 11/98
login(1) login(1)
Cannot open password file
The /etc/passwd file does not exist or cannot be read by login. Con-
tact the system administrator.
No utmp entry. You must execute "exec login" from the lowest level "sh".
login cannot find the right entry in /var/adm/utmp, which means that
login has not been started as a login process. Call exec login from
the login shell.
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed. The LCTIME environment variable governs
the format of date and time strings. LCCTYPE governs character
classes and character conversion (shifting).
If LCMESSAGES, LCTIME or LCCTYPE is undefined or is defined as the
null string, it defaults to the value of LANG. If LANG is likewise
undefined or null, the system acts as if it were not international-
ized.
The LCALL environment variable governs the entire locale. LCALL
takes precedence over all the other environment variables which affect
internationalization. If any of the locale variables has an invalid
value, the system acts as if none of the variables were set.
It is advisable to restrict the characters you use for login names and
passwords to those in the Portable Filename Character Set; 8-bit data
may not always be portable to non-internationalized systems.
EXAMPLES
Example 1
User rose is currently working in the Bourne shell and wishes to log
into the system again under the login name harold. The shell prompt
has been redefined in the file /home/harold/.profile as follows:
PS1=$USER
$ pwd
/usr/rose/prog
$ id
uid=104(rose) gid=12(group12)
$ exec login harold
password:
The password for harold must now be entered unseen. Following a suc-
cessful login attempt, login displays information about the time and
terminal of the last login.
harold: pwd
/home/harold
Page 6 Reliant UNIX 5.44 Printed 11/98
login(1) login(1)
Example 2
The su command can be used to switch the login name without affecting
the current working environment:
$ pwd
/usr/rose/prog
$ id
uid=104(rose) gid=12(group12)
$ su harold
password:
The password for harold must now be entered unseen.
$ pwd
/usr/rose/prog
$ echo $USER
rose
$ id
id=100(harold) gid=10(other)
NOTES
login exists both as an external command (/usr/bin/login) and as a
built-in shell command in the Korn shell ksh(1). The shell generates a
new process to execute /usr/bin/login.
Some differences in behavior may occur when using login, depending on
which command is being used. The possible differences are not
described specifically.
FILES
/etc/motd
Contains the login message (message of the day) for all users.
/etc/nologin
If this file exists, only the system administrator (root) can log
in. If another user attempts to log in, the contents of the file
/etc/nologin are output.
/etc/passwd
Contains all the login names that have been set up.
/etc/profile
Executed by each login shell. This file is created by the system
administrator.
/etc/shadow
Contains encoded passwords.
Page 7 Reliant UNIX 5.44 Printed 11/98
login(1) login(1)
/var/adm/utmp
Contains information on logins by all users currently logged in.
/var/adm/loginlog
Contains information on unsuccessful login attempts.
/var/adm/lastlog
Records for each login name the time and terminal at which the
respective user last logged in.
/var/adm/wtmp
If this file exists, all attempts to log in or out are sequen-
tially entered in it.
/var/mail/loginname
Contains mail for this login name.
$HOME/.profile
Shell script that every user can set up in his or her home direc-
tory. This file is executed by the login shell after
/etc/profile.
Note:
The C shell does not execute $HOME/.profile; see csh(1).
SEE ALSO
exec(1), newgrp(1), sh(1), su(1), defaultpasswd(4), loginlog(4),
passwd(4), profile(4), environ(5).
Page 8 Reliant UNIX 5.44 Printed 11/98