Log in
login [-fpq] [-c|u] [-h host] [-t timeout] [username [env1 env2 ...]]
Neutrino
The environment variables set in /etc/default/login are set whether or not -p is specified.
The login command starts a session associated with a user. It's used when someone either first signs on to the computer, or wishes to log in as another user. If login is invoked without a username, it prompts for one. It always prompts for a password.
This utility needs to have the setuid (“set user ID”) bit set in its permissions. If you use mkefs, mketfs, or mkifs on a Windows host to include this utility in an image, use the perms attribute to specify its permissions explicitly, and the uid and gid attributes to set the ownership correctly. |
The login command verifies the username and password against a password database and, if verified, starts the user session. If either the username or password is unacceptable, login asks again for both.
For compatibility, login checks the password using two encryption methods:
The check succeeds if either encryption matches the password. The -c and -u options allow slightly more security by allowing only one encryption method.
The login utility sets the user ID and group ID as well as the current working directory, then executes a shell according to specifications found in the password database.
If execution of the shell fails, login prints the message No Shell and exits. The shell is started with a dash (-) prepended to its name as argument 0. This informs the shell to perform its startup routine.
The login utility sets the SHELL, HOME, LOGNAME, USERNAME (same as LOGNAME), TERM (if set in the caller's environment), and PATH (set to the value defined by _CS_PATH) environment variables. For more information on setting PATH, see “Setting PATH and LD_LIBRARY_PATH” in the Configuring Your Environment chapter of the Neutrino User's Guide.
The login utility also updates system accounting information in /var/log/utmp, /var/log/wtmp, and /var/log/lastlog if they already exist.
The login utility doesn't create /var/log/utmp, /var/log/wtmp, and /var/log/lastlog if they don't already exist. These files can quickly become very big, which isn't good on an embedded system with limited resources. |
The login utility also sets the environment variables specified in the /etc/default/login file. This file lets you specify which environment variable settings are to be used across login sessions. If a variable isn't set when login is started and this file contains a default for the variable, that default is used. If the file doesn't contain a default for the variable, the variable is cleared by login. If a variable is already set when login is started and -p is specified, it's preserved, even if the /etc/default/login file contains a default for the variable. The -p option allows site-specific environment variables to be passed from the system startup processes down to applications.
You can set environment variables by specifying them on the command line after the username, in the form VARIABLE[=VALUE]. For example:
login thomasf APPLES=RED TOMATOES
adds the following to the new login environment:
APPLES = RED TOMATOES = 1
Values passed on the command line are always added to the new environment (regardless of the -p flag) and override the existing values. The SHELL, HOME, TERM, LOGNAME, USER values set by login override the command-line values.
You can specify which environment variables are to be preserved when the -p flag isn't specified, by populating an /etc/default/login file with the names of the environment variables you want to save. For example, if /etc/default/login contains:
SYSNAME TZ PHOTON
then when you run login without the -p option, the SYSNAME, TZ and PHOTON variables (if they exist) are propagated to the new environment. The values may be overwritten by values on the command line.
You can execute login only from the login shell, or when no session is active; you can't nest login commands.
If you execute login from the login shell, the shell from which it is run is terminated. This is because, by default, login is an alias for exec login.
logout, newgrp, passwd, phlogin, sh, su
crypt(), endutent(), getutent(), getutid(), getutline(), pututline(), qnx_crypt(), setutent(), utmpname() in the Library Reference
Logging In, Logging Out, and Shutting Down and Managing User Accounts in the Neutrino User's Guide