]> git.ipfire.org Git - thirdparty/util-linux.git/blob - term-utils/agetty.8
Merge branch 'script_quiet' of https://github.com/renyuneyun/util-linux
[thirdparty/util-linux.git] / term-utils / agetty.8
1 .TH AGETTY 8 "February 2016" "util-linux" "System Administration"
2 .SH NAME
3 agetty \- alternative Linux getty
4
5 .SH SYNOPSIS
6 .B agetty
7 [options]
8 .IR port " [" baud_rate "...] [" term ]
9
10 .SH DESCRIPTION
11 .ad
12 .fi
13 \fBagetty\fP opens a tty port, prompts for a login name and invokes
14 the /bin/login command. It is normally invoked by \fBinit\fP(8).
15
16 \fBagetty\fP has several \fInon-standard\fP features that are useful
17 for hardwired and for dial-in lines:
18 .IP \(bu
19 Adapts the tty settings to parity bits and to erase, kill,
20 end-of-line and uppercase characters when it reads a login name.
21 The program can handle 7-bit characters with even, odd, none or space
22 parity, and 8-bit characters with no parity. The following special
23 characters are recognized: Control-U (kill); DEL and
24 backspace (erase); carriage return and line feed (end of line).
25 See also the \fB\-\-erase\-chars\fP and \fB\-\-kill\-chars\fP options.
26 .IP \(bu
27 Optionally deduces the baud rate from the CONNECT messages produced by
28 Hayes(tm)-compatible modems.
29 .IP \(bu
30 Optionally does not hang up when it is given an already opened line
31 (useful for call-back applications).
32 .IP \(bu
33 Optionally does not display the contents of the \fI/etc/issue\fP file.
34 .IP \(bu
35 Optionally displays an alternative issue file instead of \fI/etc/issue\fP.
36 .IP \(bu
37 Optionally does not ask for a login name.
38 .IP \(bu
39 Optionally invokes a non-standard login program instead of
40 \fI/bin/login\fP.
41 .IP \(bu
42 Optionally turns on hardware flow control.
43 .IP \(bu
44 Optionally forces the line to be local with no need for carrier detect.
45 .PP
46 This program does not use the \fI/etc/gettydefs\fP (System V) or
47 \fI/etc/gettytab\fP (SunOS 4) files.
48 .SH ARGUMENTS
49 .na
50 .nf
51 .fi
52 .ad
53 .TP
54 .I port
55 A path name relative to the \fI/dev\fP directory. If a "\-" is
56 specified, \fBagetty\fP assumes that its standard input is
57 already connected to a tty port and that a connection to a
58 remote user has already been established.
59 .sp
60 Under System V, a "\-" \fIport\fP argument should be preceded
61 by a "\-\-".
62 .TP
63 .IR baud_rate ,...
64 A comma-separated list of one or more baud rates. Each time
65 \fBagetty\fP receives a BREAK character it advances through
66 the list, which is treated as if it were circular.
67 .sp
68 Baud rates should be specified in descending order, so that the
69 null character (Ctrl\-@) can also be used for baud-rate switching.
70 .sp
71 This argument is optional and unnecessary for \fBvirtual terminals\fP.
72 .sp
73 The default for \fBserial terminals\fP is keep the current baud rate
74 (see \fB\-\-keep\-baud\fP) and if unsuccessful then default to '9600'.
75 .TP
76 .I term
77 The value to be used for the TERM environment variable. This overrides
78 whatever init(8) may have set, and is inherited by login and the shell.
79 .sp
80 The default is 'vt100', or 'linux' for Linux on a virtual terminal,
81 or 'hurd' for GNU Hurd on a virtual terminal.
82 .SH OPTIONS
83 .na
84 .nf
85 .fi
86 .ad
87 .TP
88 \-8, \-\-8bits
89 Assume that the tty is 8-bit clean, hence disable parity detection.
90 .TP
91 \-a, \-\-autologin \fIusername\fP
92 Automatically log in the specified user without asking for a username or password.
93 Using this option causes an \fB\-f \fIusername\fR option and argument to be
94 added to the \fB/bin/login\fP command line. See \fB\-\-login\-options\fR, which
95 can be used to modify this option's behavior.
96 .TP
97 \-c, \-\-noreset
98 Do not reset terminal cflags (control modes). See \fBtermios\fP(3) for more
99 details.
100 .TP
101 \-E, \-\-remote
102 Typically the \fBlogin\fP(1) command is given a remote hostname when
103 called by something such as \fBtelnetd\fP(8). This option allows \fBagetty\fP
104 to pass what it is using for a hostname to \fBlogin\fP(1) for use
105 in \fButmp\fP(5). See \fB\-\-host\fP, \fBlogin\fP(1), and \fButmp\fP(5).
106 .IP
107 If the \fB\-\-host\fP \fIfakehost\fP option is given, then an \fB\-h\fP
108 \fIfakehost\fP option and argument are added to the \fB/bin/login\fP
109 command line.
110 .IP
111 If the \fB\-\-nohostname\fR option is given, then an \fB\-H\fP option
112 is added to the \fB/bin/login\fP command line.
113 .IP
114 See \fB\-\-login\-options\fR.
115 .TP
116 \-f, \-\-issue\-file \fIissue_file\fP
117 Display the contents of \fIissue_file\fP instead of \fI/etc/issue\fP.
118 This allows custom messages to be displayed on different terminals.
119 The \-\-noissue option will override this option.
120 .TP
121 \-h, \-\-flow\-control
122 Enable hardware (RTS/CTS) flow control. It is left up to the
123 application to disable software (XON/XOFF) flow protocol where
124 appropriate.
125 .TP
126 \-H, \-\-host \fIfakehost\fP
127 Write the specified \fIfakehost\fP into the utmp file. Normally,
128 no login host is given, since \fBagetty\fP is used for local hardwired
129 connections and consoles. However, this option can be useful for
130 identifying terminal concentrators and the like.
131 .TP
132 \-i, \-\-noissue
133 Do not display the contents of \fI/etc/issue\fP (or other) before writing the
134 login prompt. Terminals or communications hardware may become confused
135 when receiving lots of text at the wrong baud rate; dial-up scripts
136 may fail if the login prompt is preceded by too much text.
137 .TP
138 \-I, \-\-init\-string \fIinitstring\fP
139 Set an initial string to be sent to the tty or modem before sending
140 anything else. This may be used to initialize a modem. Non-printable
141 characters may be sent by writing their octal code preceded by a
142 backslash (\\). For example, to send a linefeed character (ASCII 10,
143 octal 012), write \\012.
144 .TP
145 \-J, \-\-noclear
146 Do not clear the screen before prompting for the login name.
147 By default the screen is cleared.
148 .TP
149 \-l, \-\-login\-program \fIlogin_program\fP
150 Invoke the specified \fIlogin_program\fP instead of /bin/login. This allows
151 the use of a non-standard login program. Such a program could, for example,
152 ask for a dial-up password or use a different password file. See
153 \fB\-\-login\-options\fP.
154 .TP
155 \-L, \-\-local\-line[=\fImode\fP]
156 Control the CLOCAL line flag. The optional \fImode\fP argument is 'auto', 'always' or 'never'.
157 If the \fImode\fP argument is omitted, then the default is 'always'. If the
158 \-\-local\-line option is not given at all, then the default is 'auto'.
159 .PP
160 .RS
161 .PD 1
162 .TP
163 \fIalways\fR
164 Forces the line to be a local line with no need for carrier detect. This
165 can be useful when you have a locally attached terminal where the serial
166 line does not set the carrier-detect signal.
167 .TP
168 \fInever\fR
169 Explicitly clears the CLOCAL flag from the line setting and the
170 carrier-detect signal is expected on the line.
171 .TP
172 \fIauto\fR
173 The \fBagetty\fR default. Does not modify the CLOCAL setting and follows
174 the setting enabled by the kernel.
175 .PD
176 .RE
177 .TP
178 \-m, \-\-extract\-baud
179 Try to extract the baud rate from the CONNECT status message
180 produced by Hayes(tm)\-compatible modems. These status
181 messages are of the form: "<junk><speed><junk>".
182 \fBagetty\fP assumes that the modem emits its status message at
183 the same speed as specified with (the first) \fIbaud_rate\fP value
184 on the command line.
185 .sp
186 Since the \fB\-\-extract\-baud\fP feature may fail on heavily-loaded
187 systems, you still should enable BREAK processing by enumerating all
188 expected baud rates on the command line.
189 .TP
190 \-n, \-\-skip\-login
191 Do not prompt the user for a login name. This can be used in connection
192 with the \fB\-\-login\-program\fP option to invoke a non-standard login
193 process such as a BBS system. Note that with the \fB\-\-skip\-login\fR
194 option, \fBagetty\fR gets no input from the user who logs in and therefore
195 will not be able to figure out parity, character size, and newline
196 processing of the connection. It defaults to space parity, 7 bit
197 characters, and ASCII CR (13) end-of-line character. Beware that the
198 program that \fBagetty\fR starts (usually /bin/login) is run as root.
199 .TP
200 \-N, \-\-nonewline
201 Do not print a newline before writing out /etc/issue.
202 .TP
203 \-o, \-\-login\-options "\fIlogin_options\fP"
204 Options and arguments that are passed to \fBlogin\fP(1). Where \\u is
205 replaced by the login name. For example:
206 .RS
207 .IP "" 4
208 .B "\-\-login\-options '-h darkstar -- \\\u'"
209 .PP
210 See \fB\-\-autologin\fR, \fB\-\-login\-program\fR and \fB\-\-remote\fR.
211 .PP
212 Please read the SECURITY NOTICE below before using this option.
213 .RE
214 .TP
215 \-p, \-\-login\-pause
216 Wait for any key before dropping to the login prompt. Can be combined
217 with \fB\-\-autologin\fP to save memory by lazily spawning shells.
218 .TP
219 \-r, \-\-chroot \fIdirectory\fP
220 Change root to the specified directory.
221 .TP
222 \-R, \-\-hangup
223 Call vhangup() to do a virtual hangup of the specified terminal.
224 .TP
225 \-s, \-\-keep\-baud
226 Try to keep the existing baud rate. The baud rates from
227 the command line are used when agetty receives a BREAK character.
228 .TP
229 \-t, \-\-timeout \fItimeout\fP
230 Terminate if no user name could be read within \fItimeout\fP seconds.
231 Use of this option with hardwired terminal lines is not recommended.
232 .TP
233 \-U, \-\-detect\-case
234 Turn on support for detecting an uppercase-only terminal. This setting
235 will detect a login name containing only capitals as indicating an
236 uppercase-only terminal and turn on some upper-to-lower case conversions.
237 Note that this has no support for any Unicode characters.
238 .TP
239 \-w, \-\-wait\-cr
240 Wait for the user or the modem to send a carriage-return or a
241 linefeed character before sending the \fI/etc/issue\fP file (or others)
242 and the login prompt. This is useful with the \fB\-\-init\-string\fP
243 option.
244 .TP
245 \-\-nohints
246 Do not print hints about Num, Caps and Scroll Locks.
247 .TP
248 \-\-nohostname
249 By default the hostname will be printed. With this option enabled,
250 no hostname at all will be shown.
251 .TP
252 \-\-long\-hostname
253 By default the hostname is only printed until the first dot. With
254 this option enabled, the fully qualified hostname by \fBgethostname\fR(3P)
255 or (if not found) by \fBgetaddrinfo\fR(3) is shown.
256 .TP
257 \-\-erase\-chars \fIstring\fP
258 This option specifies additional characters that should be interpreted as a
259 backspace ("ignore the previous character") when the user types the login name.
260 The default additional \'erase\' has been \'#\', but since util-linux 2.23
261 no additional erase characters are enabled by default.
262 .TP
263 \-\-kill\-chars \fIstring\fP
264 This option specifies additional characters that should be interpreted as a
265 kill ("ignore all previous characters") when the user types the login name.
266 The default additional \'kill\' has been \'@\', but since util-linux 2.23
267 no additional kill characters are enabled by default.
268 .TP
269 \-\-chdir \fIdirectory\fP
270 Change directory before the login.
271 .TP
272 \-\-delay \fInumber\fP
273 Sleep seconds before open tty.
274 .TP
275 \-\-nice \fInumber\fP
276 Run login with this priority.
277 .TP
278 \-\-reload
279 Ask all running agetty instances to reload and update their displayed prompts,
280 if the user has not yet commenced logging in. After doing so the command will
281 exit. This feature might be unsupported on systems without Linux
282 .BR inotify (7).
283 .TP
284 \-\-version
285 Display version information and exit.
286 .TP
287 \-\-help
288 Display help text and exit.
289 .PP
290 .SH EXAMPLES
291 This section shows examples for the process field of an entry in the
292 \fI/etc/inittab\fP file. You'll have to prepend appropriate values
293 for the other fields. See \fIinittab(5)\fP for more details.
294
295 For a hardwired line or a console tty:
296
297 .RS
298 .B /sbin/agetty\ 9600\ ttyS1
299 .RE
300
301 For a directly connected terminal without proper carrier-detect wiring
302 (try this if your terminal just sleeps instead of giving you a password:
303 prompt):
304
305 .RS
306 .B /sbin/agetty\ \-\-local\-line\ 9600\ ttyS1\ vt100
307 .RE
308
309 For an old-style dial-in line with a 9600/2400/1200 baud modem:
310
311 .RS
312 .B /sbin/agetty\ \-\-extract\-baud\ \-\-timeout\ 60\ ttyS1\ 9600,2400,1200
313 .RE
314
315 For a Hayes modem with a fixed 115200 bps interface to the machine
316 (the example init string turns off modem echo and result codes, makes
317 modem/computer DCD track modem/modem DCD, makes a DTR drop cause a
318 disconnection, and turns on auto-answer after 1 ring):
319
320 .RS
321 .B /sbin/agetty\ \-\-wait\-cr\ \-\-init\-string\ 'ATE0Q1&D2&C1S0=1\\015'\ 115200\ ttyS1
322 .RE
323
324 .SH SECURITY NOTICE
325 If you use the \fB\-\-login\-program\fP and \fB\-\-login\-options\fP options,
326 be aware that a malicious user may try to enter lognames with embedded options,
327 which then get passed to the used login program. Agetty does check
328 for a leading "\-" and makes sure the logname gets passed as one parameter
329 (so embedded spaces will not create yet another parameter), but depending
330 on how the login binary parses the command line that might not be sufficient.
331 Check that the used login program cannot be abused this way.
332 .PP
333 Some programs use "\-\-" to indicate that the rest of the commandline should
334 not be interpreted as options. Use this feature if available by passing "\-\-"
335 before the username gets passed by \\u.
336
337 .SH ISSUE ESCAPES
338 The issue-file (\fI/etc/issue\fP, or the file set with the \fB\-\-issue\-file\fP option)
339 may contain certain escape codes to display the system name, date, time
340 etcetera. All escape codes consist of a backslash (\\) immediately
341 followed by one of the characters listed below.
342
343 .TP
344 4 or 4{\fIinterface\fR}
345 Insert the IPv4 address of the specified network interface (for example: \\4{eth0}).
346 If the \fIinterface\fR argument is not specified, then select the first fully
347 configured (UP, non-LOCALBACK, RUNNING) interface. If not any configured
348 interface is found, fall back to the IP address of the machine's hostname.
349 .TP
350 6 or 6{\fIinterface\fR}
351 The same as \\4 but for IPv6.
352 .TP
353 b
354 Insert the baudrate of the current line.
355 .TP
356 d
357 Insert the current date.
358 .TP
359 e or e{\fIname\fR}
360 Translate the human-readable \fIname\fP to an escape sequence and insert it
361 (for example: \\e{red}Alert text.\\e{reset}). If the \fIname\fR argument is
362 not specified, then insert \\033. The currently supported names are: black,
363 blink, blue, bold, brown, cyan,
364 darkgray, gray, green, halfbright, lightblue, lightcyan, lightgray, lightgreen,
365 lightmagenta, lightred, magenta, red, reset, reverse, and yellow. All unknown
366 names are silently ignored.
367 .TP
368 s
369 Insert the system name (the name of the operating system). Same as 'uname \-s'.
370 See also the \\S escape code.
371 .TP
372 S or S{VARIABLE}
373 Insert the VARIABLE data from \fI/etc/os-release\fP. If this file does not exist
374 then fall back to \fI/usr/lib/os-release\fP. If the VARIABLE argument is not
375 specified, then use PRETTY_NAME from the file or the system name (see \\s).
376 This escape code allows to keep \fI/etc/issue\fP distribution and release
377 independent. Note that \\S{ANSI_COLOR} is converted to the real terminal
378 escape sequence.
379 .TP
380 l
381 Insert the name of the current tty line.
382 .TP
383 m
384 Insert the architecture identifier of the machine. Same as 'uname \-m'.
385 .TP
386 n
387 Insert the nodename of the machine, also known as the hostname. Same as 'uname \-n'.
388 .TP
389 o
390 Insert the NIS domainname of the machine. Same as 'hostname \-d'.
391 .TP
392 O
393 Insert the DNS domainname of the machine.
394 .TP
395 r
396 Insert the release number of the OS. Same as 'uname \-r'.
397 .TP
398 t
399 Insert the current time.
400 .TP
401 u
402 Insert the number of current users logged in.
403 .TP
404 U
405 Insert the string "1 user" or "<n> users" where <n> is the number of current
406 users logged in.
407 .TP
408 v
409 Insert the version of the OS, that is, the build-date and such.
410 .PP
411 An example. On my system, the following \fI/etc/issue\fP file:
412 .sp
413 .na
414 .RS
415 .nf
416 This is \\n.\\o (\\s \\m \\r) \\t
417 .fi
418 .RE
419 .PP
420 displays as:
421 .sp
422 .RS
423 .nf
424 This is thingol.orcan.dk (Linux i386 1.1.9) 18:29:30
425 .fi
426 .RE
427
428 .SH FILES
429 .na
430 .TP
431 .I /var/run/utmp
432 the system status file.
433 .TP
434 .I /etc/issue
435 printed before the login prompt.
436 .TP
437 .I /etc/os-release /usr/lib/os-release
438 operating system identification data.
439 .TP
440 .I /dev/console
441 problem reports (if syslog(3) is not used).
442 .TP
443 .I /etc/inittab
444 \fIinit\fP(8) configuration file for SysV-style init daemon.
445 .SH BUGS
446 .ad
447 .fi
448 The baud-rate detection feature (the \fB\-\-extract\-baud\fP option) requires that
449 \fBagetty\fP be scheduled soon enough after completion of a dial-in
450 call (within 30 ms with modems that talk at 2400 baud). For robustness,
451 always use the \fB\-\-extract\-baud\fP option in combination with a multiple baud
452 rate command-line argument, so that BREAK processing is enabled.
453
454 The text in the \fI/etc/issue\fP file (or other) and the login prompt
455 are always output with 7-bit characters and space parity.
456
457 The baud-rate detection feature (the \fB\-\-extract\-baud\fP option) requires that
458 the modem emits its status message \fIafter\fP raising the DCD line.
459 .SH DIAGNOSTICS
460 .ad
461 .fi
462 Depending on how the program was configured, all diagnostics are
463 written to the console device or reported via the \fBsyslog\fR(3) facility.
464 Error messages are produced if the \fIport\fP argument does not
465 specify a terminal device; if there is no utmp entry for the
466 current process (System V only); and so on.
467 .SH AUTHORS
468 .UR werner@suse.de
469 Werner Fink
470 .UE
471 .br
472 .UR kzak@redhat.com
473 Karel Zak
474 .UE
475 .sp
476 The original
477 .B agetty
478 for serial terminals was written by W.Z. Venema <wietse@wzv.win.tue.nl>
479 and ported to Linux by Peter Orbaek <poe@daimi.aau.dk>.
480
481 .SH AVAILABILITY
482 The agetty command is part of the util-linux package and is available from
483 https://www.kernel.org/pub/linux/utils/util\-linux/.