Updated: April 19, 2023 |
Log in
login [-fpq] [-h host] [-t timeout] [username [env1 env2 ...]]
QNX 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.
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.
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, USER (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 QNX 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 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
then when you run login without the -p option, the SYSNAME and TZ 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.