Log into the computer.
If no user is specified, or if password authentication of the user fails, login prompts for a user name.
Syntax login [-fp] [-h hostname] [user] login -f [-lpq] [-h hostname] [user [prog [args...]]] Options -f The -f option is used when a user name is specified to indicate that proper authentication has already been done and that no password need be requested. This option can only be used by the super-user or when an already logged in user is logging in as themselves. -h The -h option specifies the host from which the connection was received. It is used by various daemons such as telnetd(8). This option can only be used by the super-user. -l Tells the program executed by login that this is not a login session (by convention, a login session is signalled to the program with a hyphen as the first character of argv; this option disables that), and prevents it from chdir(2)ing to the user's home directory. The default is to add the hyphen (this is a login session). -p By default, login discards any previous environment. The -p option disables this behavior. -q This forces quiet logins, as if a .hushlogin is present.
If the file /etc/nologin exists, login dislays its contents to the user and exits. This is used by shutdown to prevent users from logging in when the system is about to go down.
Immediately after logging a user in, login displays the system copyright notice, the date and time the user last logged in, the message of the day as well as other information. If the file `.hushlogin' exists in the user's home directory, all of these messages are suppressed. This is to simplify logins for non-human users, such as uucp(1). Login then records an entry in the wtmp(5) and utmp(5) files and executes the user's command interpreter.
Login enters information into the environment (see environ(7)) specifying the user's home directory (HOME), command interpreter (SHELL), search path (PATH), terminal type (TERM) and user name (both LOGNAME and USER).
The login utility will submit an audit record when login succeeds or fails. Failure to determine the current auditing state will result in an error exit from login.
/etc/nologin disallows logins
/var/run/utmpx current logins
/var/mail/user system mailboxes
.hushlogin makes login quieter
/etc/security/audit_user user flags for auditing
/etc/security/audit_control global flags for auditing
“Leave behind all hope, ye who enter here“ ~ sign above the entrance to Dante's hell
Related macOS commands:
passwd - Modify a user password
rlogin - Connect to remote host system