]> git.ipfire.org Git - thirdparty/util-linux.git/blame - login-utils/login.1
swapon: add error messages for lseek and write
[thirdparty/util-linux.git] / login-utils / login.1
CommitLineData
6dbe3af9
KZ
1.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
2.\" May be distributed under the GNU General Public License
fd6b7a7f 3.TH LOGIN 1 "4 November 1996" "Util-linux 1.6" "Linux Programmer's Manual"
6dbe3af9
KZ
4.SH NAME
5login \- sign on
6.SH SYNOPSIS
7.BR "login [ " name " ]"
8.br
9.B "login \-p"
10.br
11.BR "login \-h " hostname
12.br
13.BR "login \-f " name
14.SH DESCRIPTION
15.B login
16is used when signing onto a system. It can also be used to switch from one
17user to another at any time (most modern shells have support for this
18feature built into them, however).
19
20If an argument is not given,
21.B login
22prompts for the username.
23
24If the user is
25.I not
26root, and if
27.I /etc/nologin
7eda085c 28exists, the contents of this file are printed to the screen, and the
6dbe3af9
KZ
29login is terminated. This is typically used to prevent logins when the
30system is being taken down.
31
726f69e2
KZ
32If special access restrictions are specified for the user in
33.IR /etc/usertty ,
34these must be met, or the log in attempt will be denied and a
35.B syslog
36message will be generated. See the section on "Special Access Restrictions".
37
eb63b9b8 38If the user is root, then the login must be occurring on a tty listed in
6dbe3af9
KZ
39.IR /etc/securetty .
40Failures will be logged with the
41.B syslog
42facility.
43
eb63b9b8
KZ
44After these conditions have been checked, the password will be requested and
45checked (if a password is required for this username). Ten attempts
fd6b7a7f 46are allowed before
6dbe3af9
KZ
47.B login
48dies, but after the first three, the response starts to get very slow.
49Login failures are reported via the
50.B syslog
51facility. This facility is also used to report any successful root logins.
52
53If the file
54.I .hushlogin
fd6b7a7f 55exists, then a "quiet" login is performed (this disables the checking
eb63b9b8
KZ
56of mail and the printing of the last login time and message of the day).
57Otherwise, if
726f69e2 58.I /var/log/lastlog
fd6b7a7f
KZ
59exists, the last login time is printed (and the current login is
60recorded).
6dbe3af9 61
fd6b7a7f
KZ
62Random administrative things, such as setting the UID and GID of the
63tty are performed. The TERM environment variable is preserved, if it
64exists (other environment variables are preserved if the
6dbe3af9
KZ
65.B \-p
66option is used). Then the HOME, PATH, SHELL, TERM, MAIL, and LOGNAME
67environment variables are set. PATH defaults to
b22550fa 68.I /usr/local/bin:/bin:/usr/bin
6dbe3af9 69for normal users, and to
b22550fa 70.I /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
fd6b7a7f
KZ
71for root. Last, if this is not a "quiet" login, the message of the
72day is printed and the file with the user's name in
cad18f61 73.I /var/spool/mail
6dbe3af9
KZ
74will be checked, and a message printed if it has non-zero length.
75
fd6b7a7f
KZ
76The user's shell is then started. If no shell is specified for the
77user in
6dbe3af9
KZ
78.BR /etc/passwd ,
79then
80.B /bin/sh
81is used. If there is no directory specified in
82.IR /etc/passwd ,
83then
84.I /
85is used (the home directory is checked for the
86.I .hushlogin
87file described above).
88.SH OPTIONS
89.TP
90.B \-p
91Used by
92.BR getty (8)
93to tell
94.B login
95not to destroy the environment
96.TP
97.B \-f
98Used to skip a second login authentication. This specifically does
99.B not
100work for root, and does not appear to work well under Linux.
101.TP
102.B \-h
103Used by other servers (i.e.,
104.BR telnetd (8))
105to pass the name of the remote host to
106.B login
fd6b7a7f
KZ
107so that it may be placed in utmp and wtmp. Only the superuser may use
108this option.
726f69e2
KZ
109
110.SH "SPECIAL ACCESS RESTRICTIONS"
111The file
112.I /etc/securetty
fd6b7a7f
KZ
113lists the names of the ttys where root is allowed to log in. One name
114of a tty device without the /dev/ prefix must be specified on each
115line. If the file does not exist, root is allowed to log in on any
116tty.
726f69e2 117.PP
a2c5f3ca
KZ
118On most modern Linux systems PAM (Pluggable Authentication Modules)
119is used. On systems that do not use PAM, the file
726f69e2 120.I /etc/usertty
a2c5f3ca
KZ
121specifies additional access restrictions for specific users.
122If this file does not exist, no additional access restrictions are
fd6b7a7f
KZ
123imposed. The file consists of a sequence of sections. There are three
124possible section types: CLASSES, GROUPS and USERS. A CLASSES section
125defines classes of ttys and hostname patterns, A GROUPS section
126defines allowed ttys and hosts on a per group basis, and a USERS
127section defines allowed ttys and hosts on a per user basis.
726f69e2 128.PP
fd6b7a7f
KZ
129Each line in this file in may be no longer than 255
130characters. Comments start with # character and extend to the end of
131the line.
726f69e2
KZ
132.PP
133.SS "The CLASSES Section"
fd6b7a7f
KZ
134A CLASSES section begins with the word CLASSES at the start of a line
135in all upper case. Each following line until the start of a new
136section or the end of the file consists of a sequence of words
137separated by tabs or spaces. Each line defines a class of ttys and
138host patterns.
726f69e2 139.PP
fd6b7a7f
KZ
140The word at the beginning of a line becomes defined as a collective
141name for the ttys and host patterns specified at the rest of the
142line. This collective name can be used in any subsequent GROUPS or
143USERS section. No such class name must occur as part of the definition
144of a class in order to avoid problems with recursive classes.
726f69e2
KZ
145.PP
146An example CLASSES section:
147.PP
148.nf
149.in +.5
150CLASSES
151myclass1 tty1 tty2
152myclass2 tty3 @.foo.com
153.in -.5
154.fi
155.PP
156This defines the classes
157.I myclass1
158and
159.I myclass2
160as the corresponding right hand sides.
161.PP
162
fd6b7a7f 163.SS "The GROUPS Section"
726f69e2
KZ
164A GROUPS section defines allowed ttys and hosts on a per Unix group basis. If
165a user is a member of a Unix group according to
166.I /etc/passwd
167and
168.I /etc/group
169and such a group is mentioned in a GROUPS section in
170.I /etc/usertty
171then the user is granted access if the group is.
172.PP
173A GROUPS section starts with the word GROUPS in all upper case at the start of
174a line, and each following line is a sequence of words separated by spaces
175or tabs. The first word on a line is the name of the group and the rest
176of the words on the line specifies the ttys and hosts where members of that
177group are allowed access. These specifications may involve the use of
178classes defined in previous CLASSES sections.
179.PP
180An example GROUPS section.
181.PP
182.nf
183.in +0.5
184GROUPS
185sys tty1 @.bar.edu
186stud myclass1 tty4
187.in -0.5
188.fi
189.PP
190This example specifies that members of group
191.I sys
fd6b7a7f
KZ
192may log in on tty1 and from hosts in the bar.edu domain. Users in
193group
726f69e2 194.I stud
fd6b7a7f
KZ
195may log in from hosts/ttys specified in the class myclass1 or from
196tty4.
726f69e2
KZ
197.PP
198
199.SS "The USERS Section"
200A USERS section starts with the word USERS in all upper case at the
201start of a line, and each following line is a sequence of words
202separated by spaces or tabs. The first word on a line is a username
203and that user is allowed to log in on the ttys and from the hosts
204mentioned on the rest of the line. These specifications may involve
205classes defined in previous CLASSES sections. If no section header is
206specified at the top of the file, the first section defaults to be a
207USERS section.
208.PP
209An example USERS section:
210.PP
211.nf
212.in +0.5
213USERS
214zacho tty1 @130.225.16.0/255.255.255.0
215blue tty3 myclass2
216.in -0.5
217.fi
218.PP
fd6b7a7f
KZ
219This lets the user zacho login only on tty1 and from hosts with IP
220addreses in the range 130.225.16.0 \- 130.225.16.255, and user blue is
221allowed to log in from tty3 and whatever is specified in the class
222myclass2.
726f69e2 223.PP
fd6b7a7f
KZ
224There may be a line in a USERS section starting with a username of
225*. This is a default rule and it will be applied to any user not
226matching any other line.
726f69e2 227.PP
fd6b7a7f
KZ
228If both a USERS line and GROUPS line match a user then the user is
229allowed access from the union of all the ttys/hosts mentioned in these
230specifications.
726f69e2
KZ
231
232.SS Origins
fd6b7a7f
KZ
233The tty and host pattern specifications used in the specification of
234classes, group and user access are called origins. An origin string
235may have one of these formats:
726f69e2
KZ
236.IP o
237The name of a tty device without the /dev/ prefix, for example tty1 or
238ttyS0.
239.PP
240.IP o
fd6b7a7f
KZ
241The string @localhost, meaning that the user is allowed to
242telnet/rlogin from the local host to the same host. This also allows
243the user to for example run the command: xterm -e /bin/login.
726f69e2
KZ
244.PP
245.IP o
246A domain name suffix such as @.some.dom, meaning that the user may
7eda085c
KZ
247rlogin/telnet from any host whose domain name has the suffix
248\&.some.dom.
726f69e2
KZ
249.PP
250.IP o
fd6b7a7f
KZ
251A range of IPv4 addresses, written @x.x.x.x/y.y.y.y where x.x.x.x is
252the IP address in the usual dotted quad decimal notation, and y.y.y.y
253is a bitmask in the same notation specifying which bits in the address
254to compare with the IP address of the remote host. For example
726f69e2 255@130.225.16.0/255.255.254.0 means that the user may rlogin/telnet from
fd6b7a7f
KZ
256any host whose IP address is in the range 130.225.16.0 \-
257130.225.17.255.
726f69e2 258.PP
ea6c190a
KZ
259.IP o
260An range of IPv6 addresses, written @[n:n:n:n:n:n:n:n]/m is interpreted as a
261[net]/prefixlen pair. An IPv6 host address is matched if prefixlen bits of
262net is equal to the prefixlen bits of the address. For example, the
263[net]/prefixlen pattern [3ffe:505:2:1::]/64 matches every address in the
264range 3ffe:505:2:1:: through 3ffe:505:2:1:ffff:ffff:ffff:ffff.
265.PP
fd6b7a7f
KZ
266Any of the above origins may be prefixed by a time specification
267according to the syntax:
726f69e2
KZ
268.PP
269.nf
270timespec ::= '[' <day-or-hour> [':' <day-or-hour>]* ']'
271day ::= 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun'
272hour ::= '0' | '1' | ... | '23'
273hourspec ::= <hour> | <hour> '\-' <hour>
274day-or-hour ::= <day> | <hourspec>
275.fi
276.PP
fd6b7a7f
KZ
277For example, the origin [mon:tue:wed:thu:fri:8\-17]tty3 means that log
278in is allowed on mondays through fridays between 8:00 and 17:59 (5:59
279pm) on tty3. This also shows that an hour range a\-b includes all
280moments between a:00 and b:59. A single hour specification (such as
28110) means the time span between 10:00 and 10:59.
726f69e2 282.PP
fd6b7a7f
KZ
283Not specifying any time prefix for a tty or host means log in from
284that origin is allowed any time. If you give a time prefix be sure to
285specify both a set of days and one or more hours or hour ranges. A
286time specification may not include any white space.
726f69e2
KZ
287.PP
288If no default rule is given then users not matching any line
289.I /etc/usertty
290are allowed to log in from anywhere as is standard behavior.
291.PP
6dbe3af9
KZ
292.SH FILES
293.nf
726f69e2
KZ
294.I /var/run/utmp
295.I /var/log/wtmp
296.I /var/log/lastlog
cad18f61 297.I /var/spool/mail/*
6dbe3af9
KZ
298.I /etc/motd
299.I /etc/passwd
300.I /etc/nologin
726f69e2 301.I /etc/usertty
6dbe3af9
KZ
302.I .hushlogin
303.fi
304.SH "SEE ALSO"
305.BR init (8),
306.BR getty (8),
307.BR mail (1),
308.BR passwd (1),
309.BR passwd (5),
310.BR environ (7),
311.BR shutdown (8)
312.SH BUGS
fd6b7a7f 313
6dbe3af9
KZ
314The undocumented BSD
315.B \-r
316option is not supported. This may be required by some
317.BR rlogind (8)
318programs.
7eda085c
KZ
319
320A recursive login, as used to be possible in the good old days,
321no longer works; for most purposes
322.BR su (1)
323is a satisfactory substitute. Indeed, for security reasons,
324login does a vhangup() system call to remove any possible
325listening processes on the tty. This is to avoid password
326sniffing. If one uses the command "login", then the surrounding shell
327gets killed by vhangup() because it's no longer the true owner of the tty.
328This can be avoided by using "exec login" in a top-level shell or xterm.
6dbe3af9 329.SH AUTHOR
fd6b7a7f
KZ
330Derived from BSD login 5.40 (5/9/89) by Michael Glad (glad@daimi.dk)
331for HP-UX
6dbe3af9
KZ
332.br
333Ported to Linux 0.12: Peter Orbaek (poe@daimi.aau.dk)
86d62711
KZ
334.SH AVAILABILITY
335The login command is part of the util-linux-ng package and is available from
336ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.