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