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