1STTY(1P) POSIX Programmer's Manual STTY(1P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 stty - set the options for a terminal
13
15 stty [ -a| -g]
16
17 stty operands
18
19
21 The stty utility shall set or report on terminal I/O characteristics
22 for the device that is its standard input. Without options or operands
23 specified, it shall report the settings of certain characteristics,
24 usually those that differ from implementation-defined defaults. Other‐
25 wise, it shall modify the terminal state according to the specified op‐
26 erands. Detailed information about the modes listed in the first five
27 groups below are described in the Base Definitions volume of
28 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface. Operands
29 in the Combination Modes group (see Combination Modes ) are implemented
30 using operands in the previous groups. Some combinations of operands
31 are mutually-exclusive on some terminal types; the results of using
32 such combinations are unspecified.
33
34 Typical implementations of this utility require a communications line
35 configured to use the termios interface defined in the System Inter‐
36 faces volume of IEEE Std 1003.1-2001. On systems where none of these
37 lines are available, and on lines not currently configured to support
38 the termios interface, some of the operands need not affect terminal
39 characteristics.
40
42 The stty utility shall conform to the Base Definitions volume of
43 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
44
45 The following options shall be supported:
46
47 -a Write to standard output all the current settings for the termi‐
48 nal.
49
50 -g Write to standard output all the current settings in an unspeci‐
51 fied form that can be used as arguments to another invocation of
52 the stty utility on the same system. The form used shall not
53 contain any characters that would require quoting to avoid word
54 expansion by the shell; see Word Expansions .
55
56
58 The following operands shall be supported to set the terminal charac‐
59 teristics.
60
61 Control Modes
62 parenb (-parenb)
63 Enable (disable) parity generation and detection. This shall
64 have the effect of setting (not setting) PARENB in the termios
65 c_cflag field, as defined in the Base Definitions volume of
66 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
67
68 parodd (-parodd)
69
70 Select odd (even) parity. This shall have the effect of setting
71 (not setting) PARODD in the termios c_cflag field, as defined in
72 the Base Definitions volume of IEEE Std 1003.1-2001, Chapter 11,
73 General Terminal Interface.
74
75 cs5 cs6 cs7 cs8
76 Select character size, if possible. This shall have the effect
77 of setting CS5, CS6, CS7, and CS8, respectively, in the termios
78 c_cflag field, as defined in the Base Definitions volume of
79 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
80
81 number Set terminal baud rate to the number given, if possible. If the
82 baud rate is set to zero, the modem control lines shall no
83 longer be asserted. This shall have the effect of setting the
84 input and output termios baud rate values as defined in the Base
85 Definitions volume of IEEE Std 1003.1-2001, Chapter 11, General
86 Terminal Interface.
87
88 ispeed number
89 Set terminal input baud rate to the number given, if possible.
90 If the input baud rate is set to zero, the input baud rate shall
91 be specified by the value of the output baud rate. This shall
92 have the effect of setting the input termios baud rate values as
93 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
94 Chapter 11, General Terminal Interface.
95
96 ospeed number
97 Set terminal output baud rate to the number given, if possible.
98 If the output baud rate is set to zero, the modem control lines
99 shall no longer be asserted. This shall have the effect of set‐
100 ting the output termios baud rate values as defined in the Base
101 Definitions volume of IEEE Std 1003.1-2001, Chapter 11, General
102 Terminal Interface.
103
104 hupcl (-hupcl)
105 Stop asserting modem control lines (do not stop asserting modem
106 control lines) on last close. This shall have the effect of set‐
107 ting (not setting) HUPCL in the termios c_cflag field, as
108 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
109 Chapter 11, General Terminal Interface.
110
111 hup (-hup)
112 Equivalent to hupcl( -hupcl).
113
114 cstopb (-cstopb)
115 Use two (one) stop bits per character. This shall have the
116 effect of setting (not setting) CSTOPB in the termios c_cflag
117 field, as defined in the Base Definitions volume of
118 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
119
120 cread (-cread)
121 Enable (disable) the receiver. This shall have the effect of
122 setting (not setting) CREAD in the termios c_cflag field, as
123 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
124 Chapter 11, General Terminal Interface.
125
126 clocal (-clocal)
127 Assume a line without (with) modem control. This shall have the
128 effect of setting (not setting) CLOCAL in the termios c_cflag
129 field, as defined in the Base Definitions volume of
130 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
131
132
133 It is unspecified whether stty shall report an error if an attempt to
134 set a Control Mode fails.
135
136 Input Modes
137 ignbrk (-ignbrk)
138 Ignore (do not ignore) break on input. This shall have the
139 effect of setting (not setting) IGNBRK in the termios c_iflag
140 field, as defined in the Base Definitions volume of
141 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
142
143 brkint (-brkint)
144 Signal (do not signal) INTR on break. This shall have the effect
145 of setting (not setting) BRKINT in the termios c_iflag field, as
146 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
147 Chapter 11, General Terminal Interface.
148
149 ignpar (-ignpar)
150 Ignore (do not ignore) bytes with parity errors. This shall have
151 the effect of setting (not setting) IGNPAR in the termios
152 c_iflag field, as defined in the Base Definitions volume of
153 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
154
155 parmrk (-parmrk)
156
157 Mark (do not mark) parity errors. This shall have the effect of
158 setting (not setting) PARMRK in the termios c_iflag field, as
159 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
160 Chapter 11, General Terminal Interface.
161
162 inpck (-inpck)
163 Enable (disable) input parity checking. This shall have the
164 effect of setting (not setting) INPCK in the termios c_iflag
165 field, as defined in the Base Definitions volume of
166 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
167
168 istrip (-istrip)
169 Strip (do not strip) input characters to seven bits. This shall
170 have the effect of setting (not setting) ISTRIP in the termios
171 c_iflag field, as defined in the Base Definitions volume of
172 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
173
174 inlcr (-inlcr)
175 Map (do not map) NL to CR on input. This shall have the effect
176 of setting (not setting) INLCR in the termios c_iflag field, as
177 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
178 Chapter 11, General Terminal Interface.
179
180 igncr (-igncr)
181 Ignore (do not ignore) CR on input. This shall have the effect
182 of setting (not setting) IGNCR in the termios c_iflag field, as
183 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
184 Chapter 11, General Terminal Interface.
185
186 icrnl (-icrnl)
187 Map (do not map) CR to NL on input. This shall have the effect
188 of setting (not setting) ICRNL in the termios c_iflag field, as
189 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
190 Chapter 11, General Terminal Interface.
191
192 ixon (-ixon)
193 Enable (disable) START/STOP output control. Output from the sys‐
194 tem is stopped when the system receives STOP and started when
195 the system receives START. This shall have the effect of setting
196 (not setting) IXON in the termios c_iflag field, as defined in
197 the Base Definitions volume of IEEE Std 1003.1-2001, Chapter 11,
198 General Terminal Interface.
199
200 ixany (-ixany)
201 Allow any character to restart output. This shall have the
202 effect of setting (not setting) IXANY in the termios c_iflag
203 field, as defined in the Base Definitions volume of
204 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
205
206 ixoff (-ixoff)
207 Request that the system send (not send) STOP characters when the
208 input queue is nearly full and START characters to resume data
209 transmission. This shall have the effect of setting (not set‐
210 ting) IXOFF in the termios c_iflag field, as defined in the Base
211 Definitions volume of IEEE Std 1003.1-2001, Chapter 11, General
212 Terminal Interface.
213
214
215 Output Modes
216 opost (-opost)
217 Post-process output (do not post-process output; ignore all
218 other output modes). This shall have the effect of setting (not
219 setting) OPOST in the termios c_oflag field, as defined in the
220 Base Definitions volume of IEEE Std 1003.1-2001, Chapter 11,
221 General Terminal Interface.
222
223 ocrnl (-ocrnl)
224 Map (do not map) CR to NL on output This shall have the effect
225 of setting (not setting) OCRNL in the termios c_oflag field, as
226 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
227 Chapter 11, General Terminal Interface.
228
229 onocr (-onocr)
230 Do not (do) output CR at column zero. This shall have the effect
231 of setting (not setting) ONOCR in the termios c_oflag field, as
232 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
233 Chapter 11, General Terminal Interface.
234
235 onlret (-onlret)
236 The terminal newline key performs (does not perform) the CR
237 function. This shall have the effect of setting (not setting)
238 ONLRET in the termios c_oflag field, as defined in the Base Def‐
239 initions volume of IEEE Std 1003.1-2001, Chapter 11, General
240 Terminal Interface.
241
242 ofill (-ofill)
243 Use fill characters (use timing) for delays. This shall have the
244 effect of setting (not setting) OFILL in the termios c_oflag
245 field, as defined in the Base Definitions volume of
246 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
247
248 ofdel (-ofdel)
249 Fill characters are DELs (NULs). This shall have the effect of
250 setting (not setting) OFDEL in the termios c_oflag field, as
251 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
252 Chapter 11, General Terminal Interface.
253
254 cr0 cr1 cr2 cr3
255 Select the style of delay for CRs. This shall have the effect of
256 setting CRDLY to CR0, CR1, CR2, or CR3, respectively, in the
257 termios c_oflag field, as defined in the Base Definitions volume
258 of IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
259
260 nl0 nl1
261 Select the style of delay for NL. This shall have the effect of
262 setting NLDLY to NL0 or NL1, respectively, in the termios
263 c_oflag field, as defined in the Base Definitions volume of
264 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
265
266 tab0 tab1 tab2 tab3
267
268 Select the style of delay for horizontal tabs. This shall have
269 the effect of setting TABDLY to TAB0, TAB1, TAB2, or TAB3,
270 respectively, in the termios c_oflag field, as defined in the
271 Base Definitions volume of IEEE Std 1003.1-2001, Chapter 11,
272 General Terminal Interface. Note that TAB3 has the effect of
273 expanding <tab>s to <space>s.
274
275 tabs (-tabs)
276 Synonym for tab0 ( tab3).
277
278 bs0 bs1
279 Select the style of delay for backspaces. This shall have the
280 effect of setting BSDLY to BS0 or BS1, respectively, in the
281 termios c_oflag field, as defined in the Base Definitions volume
282 of IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
283
284 ff0 ff1
285 Select the style of delay for form-feeds. This shall have the
286 effect of setting FFDLY to FF0 or FF1, respectively, in the
287 termios c_oflag field, as defined in the Base Definitions volume
288 of IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
289
290 vt0 vt1
291 Select the style of delay for vertical-tabs. This shall have the
292 effect of setting VTDLY to VT0 or VT1, respectively, in the
293 termios c_oflag field, as defined in the Base Definitions volume
294 of IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
295
296
297 Local Modes
298 isig (-isig)
299 Enable (disable) the checking of characters against the special
300 control characters INTR, QUIT, and SUSP. This shall have the
301 effect of setting (not setting) ISIG in the termios c_lflag
302 field, as defined in the Base Definitions volume of
303 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
304
305 icanon (-icanon)
306 Enable (disable) canonical input (ERASE and KILL processing).
307 This shall have the effect of setting (not setting) ICANON in
308 the termios c_lflag field, as defined in the Base Definitions
309 volume of IEEE Std 1003.1-2001, Chapter 11, General Terminal
310 Interface.
311
312 iexten (-iexten)
313 Enable (disable) any implementation-defined special control
314 characters not currently controlled by icanon, isig, ixon, or
315 ixoff. This shall have the effect of setting (not setting) IEX‐
316 TEN in the termios c_lflag field, as defined in the Base Defini‐
317 tions volume of IEEE Std 1003.1-2001, Chapter 11, General Termi‐
318 nal Interface.
319
320 echo (-echo)
321 Echo back (do not echo back) every character typed. This shall
322 have the effect of setting (not setting) ECHO in the termios
323 c_lflag field, as defined in the Base Definitions volume of
324 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
325
326 echoe (-echoe)
327 The ERASE character visually erases (does not erase) the last
328 character in the current line from the display, if possible.
329 This shall have the effect of setting (not setting) ECHOE in the
330 termios c_lflag field, as defined in the Base Definitions volume
331 of IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
332
333 echok (-echok)
334 Echo (do not echo) NL after KILL character. This shall have the
335 effect of setting (not setting) ECHOK in the termios c_lflag
336 field, as defined in the Base Definitions volume of
337 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
338
339 echonl (-echonl)
340 Echo (do not echo) NL, even if echo is disabled. This shall have
341 the effect of setting (not setting) ECHONL in the termios
342 c_lflag field, as defined in the Base Definitions volume of
343 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
344
345 noflsh (-noflsh)
346 Disable (enable) flush after INTR, QUIT, SUSP. This shall have
347 the effect of setting (not setting) NOFLSH in the termios
348 c_lflag field, as defined in the Base Definitions volume of
349 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface.
350
351 tostop (-tostop)
352 Send SIGTTOU for background output. This shall have the effect
353 of setting (not setting) TOSTOP in the termios c_lflag field, as
354 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
355 Chapter 11, General Terminal Interface.
356
357
358 Special Control Character Assignments
359 <control>-character string
360
361 Set <control>-character to string. If <control>-character is one
362 of the character sequences in the first column of the following
363 table, the corresponding Base Definitions volume of
364 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface
365 control character from the second column shall be recognized.
366 This has the effect of setting the corresponding element of the
367 termios c_cc array (see the Base Definitions volume of
368 IEEE Std 1003.1-2001, Chapter 13, Headers, <termios.h>).
369
370 Table: Control Character Names in stty
371
372 Control Character c_cc Subscript Description
373 eof VEOF EOF character
374 eol VEOL EOL character
375 erase VERASE ERASE character
376 intr VINTR INTR character
377 kill VKILL KILL character
378 quit VQUIT QUIT character
379 susp VSUSP SUSP character
380 start VSTART START character
381 stop VSTOP STOP character
382
383 If string is a single character, the control character shall be set to
384 that character. If string is the two-character sequence "^-" or the
385 string undef, the control character shall be set to _POSIX_VDISABLE, if
386 it is in effect for the device; if _POSIX_VDISABLE is not in effect for
387 the device, it shall be treated as an error. In the POSIX locale, if
388 string is a two-character sequence beginning with circumflex ( '^' ),
389 and the second character is one of those listed in the "^c" column of
390 the following table, the control character shall be set to the corre‐
391 sponding character value in the Value column of the table.
392
393 Table: Circumflex Control Characters in stty
394
395 ^c Value ^c Value ^c Value
396
397 a, A <SOH> l, L <FF> w, W <ETB>
398 b, B <STX> m, M <CR> x, X <CAN>
399 c, C <ETX> n, N <SO> y, Y <EM>
400 d, D <EOT> o, O <SI> z, Z <SUB>
401 e, E <ENQ> p, P <DLE> [ <ESC>
402 f, F <ACK> q, Q <DC1> \ <FS>
403 g, G <BEL> r, R <DC2> ] <GS>
404 h, H <BS> s, S <DC3> ^ <RS>
405 i, I <HT> t, T <DC4> ──────── <US>
406 j, J <LF> u, U <NAK> ? <DEL>
407 k, K <VT> v, V <SYN>
408
409 min number
410
411 Set the value of MIN to number. MIN is used in non-canonical
412 mode input processing ( icanon).
413
414 time number
415
416 Set the value of TIME to number. TIME is used in non-canonical
417 mode input processing ( icanon).
418
419
420 Combination Modes
421 saved settings
422
423 Set the current terminal characteristics to the saved settings
424 produced by the -g option.
425
426 evenp or parity
427
428 Enable parenb and cs7; disable parodd.
429
430 oddp
431
432 Enable parenb, cs7, and parodd.
433
434 -parity, -evenp, or -oddp
435
436 Disable parenb, and set cs8.
437
438 raw (-raw or cooked)
439
440 Enable (disable) raw input and output. Raw mode shall be equiva‐
441 lent to setting:
442
443
444 stty cs8 erase ^- kill ^- intr ^- \
445 quit ^- eof ^- eol ^- -post -inpck
446
447 nl (-nl)
448
449 Disable (enable) icrnl. In addition, -nl unsets inlcr and igncr.
450
451 ek Reset ERASE and KILL characters back to system defaults.
452
453 sane
454
455 Reset all modes to some reasonable, unspecified, values.
456
457
459 Although no input is read from standard input, standard input shall be
460 used to get the current terminal I/O characteristics and to set new
461 terminal I/O characteristics.
462
464 None.
465
467 The following environment variables shall affect the execution of stty:
468
469 LANG Provide a default value for the internationalization variables
470 that are unset or null. (See the Base Definitions volume of
471 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
472 ables for the precedence of internationalization variables used
473 to determine the values of locale categories.)
474
475 LC_ALL If set to a non-empty string value, override the values of all
476 the other internationalization variables.
477
478 LC_CTYPE
479 This variable determines the locale for the interpretation of
480 sequences of bytes of text data as characters (for example, sin‐
481 gle-byte as opposed to multi-byte characters in arguments) and
482 which characters are in the class print.
483
484 LC_MESSAGES
485 Determine the locale that should be used to affect the format
486 and contents of diagnostic messages written to standard error.
487
488 NLSPATH
489 Determine the location of message catalogs for the processing of
490 LC_MESSAGES .
491
492
494 Default.
495
497 If operands are specified, no output shall be produced.
498
499 If the -g option is specified, stty shall write to standard output the
500 current settings in a form that can be used as arguments to another
501 instance of stty on the same system.
502
503 If the -a option is specified, all of the information as described in
504 the OPERANDS section shall be written to standard output. Unless other‐
505 wise specified, this information shall be written as <space>-separated
506 tokens in an unspecified format, on one or more lines, with an unspeci‐
507 fied number of tokens per line. Additional information may be written.
508
509 If no options or operands are specified, an unspecified subset of the
510 information written for the -a option shall be written.
511
512 If speed information is written as part of the default output, or if
513 the -a option is specified and if the terminal input speed and output
514 speed are the same, the speed information shall be written as follows:
515
516
517 "speed %d baud;", <speed>
518
519 Otherwise, speeds shall be written as:
520
521
522 "ispeed %d baud; ospeed %d baud;", <ispeed>, <ospeed>
523
524 In locales other than the POSIX locale, the word baud may be changed to
525 something more appropriate in those locales.
526
527 If control characters are written as part of the default output, or if
528 the -a option is specified, control characters shall be written as:
529
530
531 "%s = %s;", <control-character name>, <value>
532
533 where <value> is either the character, or some visual representation of
534 the character if it is non-printable, or the string undef if the char‐
535 acter is disabled.
536
538 The standard error shall be used only for diagnostic messages.
539
541 None.
542
544 None.
545
547 The following exit values shall be returned:
548
549 0 The terminal options were read or set successfully.
550
551 >0 An error occurred.
552
553
555 Default.
556
557 The following sections are informative.
558
560 The -g flag is designed to facilitate the saving and restoring of ter‐
561 minal state from the shell level. For example, a program may:
562
563
564 saveterm="$(stty -g)" # save terminal state
565 stty (new settings) # set new state
566 ... # ...
567 stty $saveterm # restore terminal state
568
569 Since the format is unspecified, the saved value is not portable across
570 systems.
571
572 Since the -a format is so loosely specified, scripts that save and
573 restore terminal settings should use the -g option.
574
576 None.
577
579 The original stty description was taken directly from System V and
580 reflected the System V terminal driver termio. It has been modified to
581 correspond to the terminal driver termios.
582
583 Output modes are specified only for XSI-conformant systems. All imple‐
584 mentations are expected to provide stty operands corresponding to all
585 of the output modes they support.
586
587 The stty utility is primarily used to tailor the user interface of the
588 terminal, such as selecting the preferred ERASE and KILL characters. As
589 an application programming utility, stty can be used within shell
590 scripts to alter the terminal settings for the duration of the script.
591
592 The termios section states that individual disabling of control charac‐
593 ters is possible through the option _POSIX_VDISABLE. If enabled, two
594 conventions currently exist for specifying this: System V uses "^-",
595 and BSD uses undef. Both are accepted by stty in this volume of
596 IEEE Std 1003.1-2001. The other BSD convention of using the letter 'u'
597 was rejected because it conflicts with the actual letter 'u', which is
598 an acceptable value for a control character.
599
600 Early proposals did not specify the mapping of "^c" to control charac‐
601 ters because the control characters were not specified in the POSIX
602 locale character set description file requirements. The control char‐
603 acter set is now specified in the Base Definitions volume of
604 IEEE Std 1003.1-2001, Chapter 3, Definitions so the historical mapping
605 is specified. Note that although the mapping corresponds to control-
606 character key assignments on many terminals that use the
607 ISO/IEC 646:1991 standard (or ASCII) character encodings, the mapping
608 specified here is to the control characters, not their keyboard encod‐
609 ings.
610
611 Since termios supports separate speeds for input and output, two new
612 options were added to specify each distinctly.
613
614 Some historical implementations use standard input to get and set ter‐
615 minal characteristics; others use standard output. Since input from a
616 login TTY is usually restricted to the owner while output to a TTY is
617 frequently open to anyone, using standard input provides fewer chances
618 of accidentally (or maliciously) altering the terminal settings of
619 other users. Using standard input also allows stty -a and stty -g out‐
620 put to be redirected for later use. Therefore, usage of standard input
621 is required by this volume of IEEE Std 1003.1-2001.
622
624 None.
625
627 Shell Command Language, the Base Definitions volume of
628 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface,
629 <termios.h>
630
632 Portions of this text are reprinted and reproduced in electronic form
633 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
634 -- Portable Operating System Interface (POSIX), The Open Group Base
635 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
636 Electrical and Electronics Engineers, Inc and The Open Group. In the
637 event of any discrepancy between this version and the original IEEE and
638 The Open Group Standard, the original IEEE and The Open Group Standard
639 is the referee document. The original Standard can be obtained online
640 at http://www.opengroup.org/unix/online.html .
641
642
643
644IEEE/The Open Group 2003 STTY(1P)