On Unix-like operating systems, the login command begins a new login session on the system.

This page covers the Linux version of login.

Description

The login program is used to establish a new session with the system. It is normally invoked automatically by responding to the “login:” prompt on the user’s terminal. login may be special to the shell and may not be invoked as a sub-process. When called from a shell, login should be executed as exec login which causes the user to exit from the current shell (and thus prevents the new logged in user to return to the session of the caller). Attempting to execute login from any shell but the login shell produces an error message.

  • Description
  • Syntax
  • Examples
  • Related commands
  • Linux commands help

The user is then prompted for a password, where appropriate. Echoing is disabled to prevent revealing the password. Only a small number of password failures are permitted before login exits and the communications link is severed.

If password aging is enabled for your account, you may be prompted for a new password before proceeding. You will be forced to provide your old password and the new password before continuing; refer to our passwd for more information.

Your user and group ID will be set according to their values in the /etc/passwd file. The value for $HOME, $SHELL, $PATH, $LOGNAME, and $MAIL are set according to the appropriate fields in the password entry. ulimit, umask and nice values may also be set according to entries in the GECOS field.

On some installations, the environment variable $TERM will be initialized to the terminal type on your tty line, as specified in /etc/ttytype.

An initialization script may also be executed; check the documentation of your command interpreter for information on init scripts.

A subsystem login is indicated by the presence of a “*” as the first character of the login shell. The given home directory will be used as the root of a new file system which the user is actually logged into.

Syntax

login [-p] [-h host] [username] [ENV=VAR…]

login [-p] [-h host] -f username

login [-p] -r host

Options

Configuration

The following configuration variables in /etc/login.defs change the behavior of this tool:

Files

The -r, -h and -f options are only used when login is invoked by root.

Examples

login computerhope.com

Attempts to log in to the host computerhope.com.

csh — The C shell command interpreter.exit — Exit the command shell.init — The parent of all processes on the system.ksh — The Korn shell command interpreter.mail — Read, compose, and manage mail.mailx — Process mail messages.newgrp — Log into a new group.passwd — Change a user’s password.rlogin — Begin a session on a remote system.rsh — Execute a command on a remote shell.sh — The Bourne shell command interpreter.telnet — Connect to a remote system using the telnet protocol.umask — Get or set the file mode creation mask.