login Command Examples in Linux

This tutorial explains Linux “login” command, options and its usage with examples.

login – sign on.

DESCRIPTION

login is used when signing onto a system. It can also be used to switch from one user to another at any time (most modern shells have support for this feature built into them, however).
If an argument is not given, login prompts for the username.

If the user is not root, and if /etc/nologin exists, the contents of this file are printed to the screen, and the login is terminated. This is typically used to prevent logins when the system is being taken down.

After these conditions have been checked, the password will be requested and checked (if a password is required for this username). Ten attempts are allowed before login dies, but after the first three, the response starts to get very slow. Login failures are reported via the syslog facility. This facility is also used to report any successful root logins. An initialization script for your command interpreter may also be executed.

advertisement
advertisement

SYNOPSIS

login [ -p ] [ -d device ] [ name [ environ ] ]


OPTIONS

-p
Used to pass environment variables to the login shell.
-d device
login accepts a device option, device. device is taken to be the path name of the TTY port login is to operate on.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

EXAMPLES

1. To log in to the system as user abc, enter the following at the login prompt

login: abc

If a password is defined, the password prompt appears. Enter your password at this prompt.

advertisement

2. Attempt to login to a domain

$ login xyz.com

Would attempt to login to the xyz domain.

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

advertisement
If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.