📄 login.1
字号:
.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu).\" May be distributed under the GNU General Public License.TH LOGIN 1 "4 November 1996" "Util-linux 1.6" "Linux Programmer's Manual".SH NAMElogin \- sign on.SH SYNOPSIS.BR "login [ " name " ]".br.B "login \-p".br.BR "login \-h " hostname.br.BR "login \-f " name.SH DESCRIPTION.B loginis used when signing onto a system. It can also be used to switch from oneuser to another at any time (most modern shells have support for thisfeature built into them, however).If an argument is not given,.B loginprompts for the username.If the user is.I notroot, and if.I /etc/nologinexists, the contents of this file are printed to the screen, and thelogin is terminated. This is typically used to prevent logins when thesystem is being taken down.If special access restrictions are specified for the user in.IR /etc/usertty ,these must be met, or the log in attempt will be denied and a .B syslogmessage will be generated. See the section on "Special Access Restrictions".If the user is root, then the login must be occurring on a tty listed in.IR /etc/securetty .Failures will be logged with the.B syslogfacility.After these conditions have been checked, the password will be requested andchecked (if a password is required for this username). Ten attemptsare allowed before.B logindies, but after the first three, the response starts to get very slow.Login failures are reported via the.B syslogfacility. This facility is also used to report any successful root logins.If the file.I .hushloginexists, then a "quiet" login is performed (this disables the checkingof mail and the printing of the last login time and message of the day).Otherwise, if.I /var/log/lastlogexists, the last login time is printed (and the current login isrecorded).Random administrative things, such as setting the UID and GID of thetty are performed. The TERM environment variable is preserved, if itexists (other environment variables are preserved if the.B \-poption is used). Then the HOME, PATH, SHELL, TERM, MAIL, and LOGNAMEenvironment variables are set. PATH defaults to.I /usr/local/bin:/bin:/usr/bin:.for normal users, and to.I /sbin:/bin:/usr/sbin:/usr/binfor root. Last, if this is not a "quiet" login, the message of theday is printed and the file with the user's name in.I /usr/spool/mailwill be checked, and a message printed if it has non-zero length.The user's shell is then started. If no shell is specified for theuser in.BR /etc/passwd ,then.B /bin/shis used. If there is no directory specified in.IR /etc/passwd ,then.I /is used (the home directory is checked for the.I .hushloginfile described above)..SH OPTIONS.TP.B \-pUsed by.BR getty (8)to tell.B loginnot to destroy the environment.TP.B \-fUsed to skip a second login authentication. This specifically does.B notwork for root, and does not appear to work well under Linux..TP.B \-hUsed by other servers (i.e.,.BR telnetd (8))to pass the name of the remote host to.B loginso that it may be placed in utmp and wtmp. Only the superuser may usethis option..SH "SPECIAL ACCESS RESTRICTIONS"The file.I /etc/securettylists the names of the ttys where root is allowed to log in. One nameof a tty device without the /dev/ prefix must be specified on eachline. If the file does not exist, root is allowed to log in on anytty..PPOn most modern Linux systems PAM (Pluggable Authentication Modules)is used. On systems that do not use PAM, the file.I /etc/userttyspecifies additional access restrictions for specific users.If this file does not exist, no additional access restrictions areimposed. The file consists of a sequence of sections. There are threepossible section types: CLASSES, GROUPS and USERS. A CLASSES sectiondefines classes of ttys and hostname patterns, A GROUPS sectiondefines allowed ttys and hosts on a per group basis, and a USERSsection defines allowed ttys and hosts on a per user basis..PPEach line in this file in may be no longer than 255characters. Comments start with # character and extend to the end ofthe line..PP.SS "The CLASSES Section"A CLASSES section begins with the word CLASSES at the start of a linein all upper case. Each following line until the start of a newsection or the end of the file consists of a sequence of wordsseparated by tabs or spaces. Each line defines a class of ttys andhost patterns..PPThe word at the beginning of a line becomes defined as a collectivename for the ttys and host patterns specified at the rest of theline. This collective name can be used in any subsequent GROUPS orUSERS section. No such class name must occur as part of the definitionof a class in order to avoid problems with recursive classes..PPAn example CLASSES section:.PP.nf.in +.5CLASSESmyclass1 tty1 tty2myclass2 tty3 @.foo.com.in -.5.fi.PPThis defines the classes .I myclass1and.I myclass2as the corresponding right hand sides..PP.SS "The GROUPS Section"A GROUPS section defines allowed ttys and hosts on a per Unix group basis. Ifa user is a member of a Unix group according to .I /etc/passwdand.I /etc/groupand such a group is mentioned in a GROUPS section in .I /etc/userttythen the user is granted access if the group is..PPA GROUPS section starts with the word GROUPS in all upper case at the start ofa line, and each following line is a sequence of words separated by spacesor tabs. The first word on a line is the name of the group and the restof the words on the line specifies the ttys and hosts where members of thatgroup are allowed access. These specifications may involve the use ofclasses defined in previous CLASSES sections..PPAn example GROUPS section..PP.nf.in +0.5GROUPSsys tty1 @.bar.edustud myclass1 tty4.in -0.5.fi.PPThis example specifies that members of group .I sysmay log in on tty1 and from hosts in the bar.edu domain. Users ingroup.I studmay log in from hosts/ttys specified in the class myclass1 or fromtty4..PP.SS "The USERS Section"A USERS section starts with the word USERS in all upper case at thestart of a line, and each following line is a sequence of wordsseparated by spaces or tabs. The first word on a line is a usernameand that user is allowed to log in on the ttys and from the hostsmentioned on the rest of the line. These specifications may involveclasses defined in previous CLASSES sections. If no section header isspecified at the top of the file, the first section defaults to be aUSERS section..PPAn example USERS section:.PP.nf.in +0.5USERSzacho tty1 @130.225.16.0/255.255.255.0blue tty3 myclass2.in -0.5.fi.PPThis lets the user zacho login only on tty1 and from hosts with IPaddreses in the range 130.225.16.0 \- 130.225.16.255, and user blue isallowed to log in from tty3 and whatever is specified in the classmyclass2..PPThere may be a line in a USERS section starting with a username of*. This is a default rule and it will be applied to any user notmatching any other line..PPIf both a USERS line and GROUPS line match a user then the user isallowed access from the union of all the ttys/hosts mentioned in thesespecifications..SS OriginsThe tty and host pattern specifications used in the specification ofclasses, group and user access are called origins. An origin stringmay have one of these formats:.IP o The name of a tty device without the /dev/ prefix, for example tty1 orttyS0..PP.IP oThe string @localhost, meaning that the user is allowed totelnet/rlogin from the local host to the same host. This also allowsthe user to for example run the command: xterm -e /bin/login..PP.IP oA domain name suffix such as @.some.dom, meaning that the user mayrlogin/telnet from any host whose domain name has the suffix\&.some.dom..PP.IP oA range of IPv4 addresses, written @x.x.x.x/y.y.y.y where x.x.x.x isthe IP address in the usual dotted quad decimal notation, and y.y.y.yis a bitmask in the same notation specifying which bits in the addressto compare with the IP address of the remote host. For example@130.225.16.0/255.255.254.0 means that the user may rlogin/telnet fromany host whose IP address is in the range 130.225.16.0 \-130.225.17.255..PPAny of the above origins may be prefixed by a time specificationaccording to the syntax:.PP.nftimespec ::= '[' <day-or-hour> [':' <day-or-hour>]* ']'day ::= 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun'hour ::= '0' | '1' | ... | '23'hourspec ::= <hour> | <hour> '\-' <hour>day-or-hour ::= <day> | <hourspec>.fi.PPFor example, the origin [mon:tue:wed:thu:fri:8\-17]tty3 means that login is allowed on mondays through fridays between 8:00 and 17:59 (5:59pm) on tty3. This also shows that an hour range a\-b includes allmoments between a:00 and b:59. A single hour specification (such as10) means the time span between 10:00 and 10:59..PPNot specifying any time prefix for a tty or host means log in fromthat origin is allowed any time. If you give a time prefix be sure tospecify both a set of days and one or more hours or hour ranges. Atime specification may not include any white space..PPIf no default rule is given then users not matching any line.I /etc/userttyare allowed to log in from anywhere as is standard behavior..PP.SH FILES.nf.I /var/run/utmp.I /var/log/wtmp.I /var/log/lastlog.I /usr/spool/mail/*.I /etc/motd.I /etc/passwd.I /etc/nologin.I /etc/usertty.I .hushlogin.fi.SH "SEE ALSO".BR init (8),.BR getty (8),.BR mail (1),.BR passwd (1),.BR passwd (5),.BR environ (7),.BR shutdown (8).SH BUGSThe undocumented BSD.B \-roption is not supported. This may be required by some.BR rlogind (8)programs.A recursive login, as used to be possible in the good old days,no longer works; for most purposes.BR su (1)is a satisfactory substitute. Indeed, for security reasons,login does a vhangup() system call to remove any possiblelistening processes on the tty. This is to avoid passwordsniffing. If one uses the command "login", then the surrounding shellgets killed by vhangup() because it's no longer the true owner of the tty.This can be avoided by using "exec login" in a top-level shell or xterm..SH AUTHORDerived from BSD login 5.40 (5/9/89) by Michael Glad (glad@daimi.dk)for HP-UX.brPorted to Linux 0.12: Peter Orbaek (poe@daimi.aau.dk)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -