Master Linux Login Command: Syntax, Options, and Real-World Examples
This guide explains the Linux login command, covering its purpose, syntax, available options such as -h, -p, -f, parameter usage, and provides practical examples illustrating how to log in, switch users, and handle authentication on systems like Slackware and CentOS.
login: User login system
Function description
The login command presents a login prompt, allowing re‑login, user switching, or changing the logged‑in identity at any time. In Slackware, you can append a username after the command to be prompted for a password. If the /etc/nologin file exists, only the root account may log in; all other users are denied.
Syntax
login [options] [arguments]Option meanings
-h: Use another server to transmit the remote host name for login, allowing it to be recorded in utmp and wtmp.
-p: Preserve environment variables during login.
-f: Skip the second authentication step.
Parameter meaning
Username: specifies the user name to log in as.
Reference examples
Example 1
When the system boots, it invokes this command to ask for the user's password, e.g.:
CentOS Linux 7 (Core)
Kernel 3.10.0-1127.el7.x86_64 on an x86_64
linuxer login: root
Password:Example 2
Logging in with a new identity:
[root@linuxer ~]# login
CentOS Linux 7 (Core)
Kernel 3.10.0-1127.el7.x86_64 on an x86_64
linuxer login:Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
