1.\" Copyright (c) 1990, 1993, 1994 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the Institute of Electrical and Electronics Engineers, Inc. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)stty.1 8.4 (Berkeley) 4/18/94 36.\" $Id: stty.1,v 1.6 1997/02/22 14:05:54 peter Exp $ 37.\" 38.Dd April 18, 1994 39.Dt STTY 1 40.Os 41.Sh NAME 42.Nm stty 43.Nd set the options for a terminal device interface 44.Sh SYNOPSIS 45.Nm stty 46.Op Fl a | Fl e | Fl g 47.Op Fl f Ar file 48.Op operands 49.Sh DESCRIPTION 50The 51.Nm stty 52utility sets or reports on terminal 53characteristics for the device that is its standard input. 54If no options or operands are specified, it reports the settings of a subset 55of characteristics as well as additional ones if they differ from their 56default values. 57Otherwise it modifies 58the terminal state according to the specified arguments. 59Some combinations of arguments are mutually 60exclusive on some terminal types. 61.Pp 62The following options are available: 63.Bl -tag -width Ds 64.It Fl a 65Display all the current settings for the terminal to standard output 66as per 67.St -p1003.2 . 68.It Fl e 69Display all the current settings for the terminal to standard output 70in the traditional 71.Tn BSD 72``all'' and ``everything'' formats. 73.It Fl f 74Open and use the terminal named by 75.Ar file 76rather than using standard input. The file is opened 77using the 78.Dv O_NONBLOCK 79flag of 80.Fn open , 81making it possible to 82set or display settings on a terminal that might otherwise 83block on the open. 84.It Fl g 85Display all the current settings for the terminal to standard output 86in a form that may be used as an argument to a subsequent invocation of 87.Nm stty 88to restore the current terminal state as per 89.St -p1003.2 . 90.El 91.Pp 92The following arguments are available to set the terminal 93characteristics: 94.Ss Control Modes: 95.Pp 96Control mode flags affect hardware characteristics associated with the 97terminal. This corresponds to the c_cflag in the termios structure. 98.Bl -tag -width Fl 99.It Cm parenb Pq Fl parenb 100Enable (disable) parity generation 101and detection. 102.It Cm parodd Pq Fl parodd 103Select odd (even) parity. 104.It Cm cs5 cs6 cs7 cs8 105Select character size, if possible. 106.It Ar number 107Set terminal baud rate to the 108number given, if possible. 109If the 110baud rate is set to zero, modem 111control is no longer 112asserted. 113.It Cm ispeed Ar number 114Set terminal input baud rate to the 115number given, if possible. 116If the 117input baud rate is set to zero, the 118input baud rate is set to the 119value of the output baud 120rate. 121.It Cm ospeed Ar number 122Set terminal output baud rate to 123the number given, if possible. 124If 125the output baud rate is set to 126zero, modem control is 127no longer asserted. 128.It Cm speed Ar number 129This sets both 130.Cm ispeed 131and 132.Cm ospeed 133to 134.Ar number . 135.It Cm hupcl Pq Fl hupcl 136Stop asserting modem control 137(do not stop asserting modem control) on last close. 138.It Cm hup Pq Fl hup 139Same as hupcl 140.Pq Fl hupcl . 141.It Cm cstopb Pq Fl cstopb 142Use two (one) stop bits per character. 143.It Cm cread Pq Fl cread 144Enable (disable) the receiver. 145.It Cm clocal Pq Fl clocal 146Assume a line without (with) modem 147control. 148.It Cm crtscts Pq Fl crtscts 149Enable RTS/CTS flow control. 150.El 151.Ss Input Modes: 152This corresponds to the c_iflag in the termios structure. 153.Bl -tag -width Fl 154.It Cm ignbrk Pq Fl ignbrk 155Ignore (do not ignore) break on 156input. 157.It Cm brkint Pq Fl brkint 158Signal (do not signal) 159.Dv INTR 160on 161break. 162.It Cm ignpar Pq Fl ignpar 163Ignore (do not ignore) characters with parity 164errors. 165.It Cm parmrk Pq Fl parmrk 166Mark (do not mark) characters with parity errors. 167.It Cm inpck Pq Fl inpck 168Enable (disable) input parity 169checking. 170.It Cm istrip Pq Fl istrip 171Strip (do not strip) input characters 172to seven bits. 173.It Cm inlcr Pq Fl inlcr 174Map (do not map) 175.Dv NL 176to 177.Dv CR 178on input. 179.It Cm igncr Pq Fl igncr 180Ignore (do not ignore) 181.Dv CR 182on input. 183.It Cm icrnl Pq Fl icrnl 184Map (do not map) 185.Dv CR 186to 187.Dv NL 188on input. 189.It Cm ixon Pq Fl ixon 190Enable (disable) 191.Dv START/STOP 192output 193control. 194Output from the system is 195stopped when the system receives 196.Dv STOP 197and started when the system 198receives 199.Dv START , 200or if 201.Cm ixany 202is set, any character restarts output. 203.It Cm ixoff Pq Fl ixoff 204Request that the system send (not 205send) 206.Dv START/STOP 207characters when 208the input queue is nearly 209empty/full. 210.It Cm ixany Pq Fl ixany 211Allow any character (allow only 212.Dv START ) 213to restart output. 214.It Cm imaxbel Pq Fl imaxbel 215The system imposes a limit of 216.Dv MAX_INPUT 217(currently 255) characters in the input queue. If 218.Cm imaxbel 219is set and the input queue limit has been reached, 220subsequent input causes the system to send an ASCII BEL 221character to the output queue (the terminal beeps at you). Otherwise, 222if 223.Cm imaxbel 224is unset and the input queue is full, the next input character causes 225the entire input and output queues to be discarded. 226.El 227.Ss Output Modes: 228This corresponds to the c_oflag of the termios structure. 229.Bl -tag -width Fl 230.It Cm opost Pq Fl opost 231Post-process output (do not 232post-process output; ignore all other 233output modes). 234.It Cm onlcr Pq Fl onlcr 235Map (do not map) 236.Dv NL 237to 238.Dv CR-NL 239on output. 240.It Cm oxtabs Pq Fl oxtabs 241Expand (do not expand) tabs to spaces on output. 242.El 243.Ss Local Modes: 244.Pp 245Local mode flags (lflags) affect various and sundry characteristics of terminal 246processing. 247Historically the term "local" pertained to new job control features 248implemented by Jim Kulp on a 249.Tn Pdp 11/70 250at 251.Tn IIASA . 252Later the driver ran on the first 253.Tn VAX 254at Evans Hall, UC Berkeley, where the job control details 255were greatly modified but the structure definitions and names 256remained essentially unchanged. 257The second interpretation of the 'l' in lflag 258is ``line discipline flag'' which corresponds to the 259.Ar c_lflag 260of the 261.Ar termios 262structure. 263.Bl -tag -width Fl 264.It Cm isig Pq Fl isig 265Enable (disable) the checking of 266characters against the special control 267characters 268.Dv INTR , QUIT , 269and 270.Dv SUSP . 271.It Cm icanon Pq Fl icanon 272Enable (disable) canonical input 273.Pf ( Dv ERASE 274and 275.Dv KILL 276processing). 277.It Cm iexten Pq Fl iexten 278Enable (disable) any implementation 279defined special control characters 280not currently controlled by icanon, 281isig, or ixon. 282.It Cm echo Pq Fl echo 283Echo back (do not echo back) every 284character typed. 285.It Cm echoe Pq Fl echoe 286The 287.Dv ERASE 288character shall (shall 289not) visually erase the last character 290in the current line from the 291display, if possible. 292.It Cm echok Pq Fl echok 293Echo (do not echo) 294.Dv NL 295after 296.Dv KILL 297character. 298.It Cm echoke Pq Fl echoke 299The 300.Dv KILL 301character shall (shall 302not) visually erase the 303the current line from the 304display, if possible. 305.It Cm echonl Pq Fl echonl 306Echo (do not echo) 307.Dv NL , 308even if echo 309is disabled. 310.It Cm echoctl Pq Fl echoctl 311If 312.Cm echoctl 313is set, echo control characters as ^X. Otherwise control characters 314echo as themselves. 315.It Cm echoprt Pq Fl echoprt 316For printing terminals. If set, echo erased characters backwards within ``\\'' 317and ``/''. Otherwise, disable this feature. 318.It Cm noflsh Pq Fl noflsh 319Disable (enable) flush after 320.Dv INTR , QUIT , SUSP . 321.It Cm tostop Pq Fl tostop 322Send (do not send) 323.Dv SIGTTOU 324for background output. This causes background jobs to stop if they attempt 325terminal output. 326.It Cm altwerase Pq Fl altwerase 327Use (do not use) an alternate word erase algorithm when processing 328.Dv WERASE 329characters. 330This alternate algorithm considers sequences of 331alphanumeric/underscores as words. 332It also skips the first preceding character in its classification 333(as a convenience since the one preceding character could have been 334erased with simply an 335.Dv ERASE 336character.) 337.It Cm mdmbuf Pq Fl mdmbuf 338If set, flow control output based on condition of Carrier Detect. Otherwise 339writes return an error if Carrier Detect is low (and Carrier is not being 340ignored with the 341.Dv CLOCAL 342flag.) 343.It Cm flusho Pq Fl flusho 344Indicates output is (is not) being discarded. 345.It Cm pendin Pq Fl pendin 346Indicates input is (is not) pending after a switch from non-canonical 347to canonical mode and will be re-input when a read becomes pending 348or more input arrives. 349.El 350.Ss Control Characters: 351.Bl -tag -width Fl 352.It Ar control-character Ar string 353Set 354.Ar control-character 355to 356.Ar string . 357If string is a single character, 358the control character is set to 359that character. 360If string is the 361two character sequence "^-" or the 362string "undef" the control character 363is disabled (i.e. set to 364.Pf { Dv _POSIX_VDISABLE Ns } . ) 365.Pp 366Recognized control-characters: 367.Bd -ragged -offset indent 368.Bl -column character Subscript 369.It control- 370.It character Subscript Description 371.It _________ _________ _______________ 372.It eof Ta Tn VEOF EOF No character 373.It eol Ta Tn VEOL EOL No character 374.It eol2 Ta Tn VEOL2 EOL2 No character 375.It erase Ta Tn VERASE ERASE No character 376.It werase Ta Tn VWERASE WERASE No character 377.It intr Ta Tn VINTR INTR No character 378.It kill Ta Tn VKILL KILL No character 379.It quit Ta Tn VQUIT QUIT No character 380.It susp Ta Tn VSUSP SUSP No character 381.It start Ta Tn VSTART START No character 382.It stop Ta Tn VSTOP STOP No character 383.It dsusp Ta Tn VDSUSP DSUSP No character 384.It lnext Ta Tn VLNEXT LNEXT No character 385.It reprint Ta Tn VREPRINT REPRINT No character 386.It status Ta Tn VSTATUS STATUS No character 387.El 388.Ed 389.It Cm min Ar number 390.It Cm time Ar number 391Set the value of min or time to 392number. 393.Dv MIN 394and 395.Dv TIME 396are used in 397Non-Canonical mode input processing 398(-icanon). 399.El 400.Ss Combination Modes: 401.Pp 402.Bl -tag -width Fl 403.It Ar saved settings 404Set the current terminal 405characteristics to the saved settings 406produced by the 407.Fl g 408option. 409.It Cm evenp No or Cm parity 410Enable parenb and cs7; disable 411parodd. 412.It Cm oddp 413Enable parenb, cs7, and parodd. 414.It Fl parity , evenp , oddp 415Disable parenb, and set cs8. 416.It Cm \&nl Pq Fl \&nl 417Enable (disable) icrnl. 418In addition 419-nl unsets inlcr and igncr. 420.It Cm ek 421Reset 422.Dv ERASE 423and 424.Dv KILL 425characters 426back to system defaults. 427.It Cm sane 428Resets all modes to reasonable values for interactive terminal use. 429.It Cm tty 430Set the line discipline to the standard terminal line discipline 431.Dv TTYDISC . 432.It Cm crt Pq Fl crt 433Set (disable) all modes suitable for a CRT display device. 434.It Cm kerninfo Pq Fl kerninfo 435Enable (disable) the system generated status line associated with 436processing a 437.Dv STATUS 438character (usually set to ^T). The status line consists of the 439system load average, the current command name, its process ID, the 440event the process is waiting on (or the status of the process), the user 441and system times, percent cpu, and current memory usage. 442.It Cm columns Ar number 443The terminal size is recorded as having 444.Ar number 445columns. 446.It Cm cols Ar number 447is an alias for 448.Cm columns. 449.It Cm rows Ar number 450The terminal size is recorded as having 451.Ar number 452rows. 453.It Cm dec 454Set modes suitable for users of Digital Equipment Corporation systems ( 455.Dv ERASE , 456.Dv KILL , 457and 458.Dv INTR 459characters are set to ^?, ^U, and ^C; 460.Dv ixany 461is disabled, and 462.Dv crt 463is enabled.) 464.It Cm extproc Pq Fl extproc 465If set, this flag indicates that some amount of terminal processing is being 466performed by either the terminal hardware or by the remote side connected 467to a pty. 468.It Cm raw Pq Fl raw 469If set, change the modes of the terminal so that no input or output processing 470is performed. If unset, change the modes of the terminal to some reasonable 471state that performs input and output processing. Note that since the 472terminal driver no longer has a single 473.Dv RAW 474bit, it is not possible to intuit what flags were set prior to setting 475.Cm raw . 476This means that unsetting 477.Cm raw 478may not put back all the setting that were previously in effect. 479To set the terminal into a raw state and then accurately restore it, the following 480shell code is recommended: 481.nf 482 483save_state=$(stty -g) 484stty raw 485\&... 486stty "$save_state" 487 488.fi 489.It Cm size 490The size of the terminal is printed as two numbers on a single line, 491first rows, then columns. 492.El 493.Ss Compatibility Modes: 494.Pp 495These modes remain for compatibility with the previous version of 496the stty command. 497.Bl -tag -width Fl 498.It Cm all 499Reports all the terminal modes as with 500.Cm stty Fl a 501except that the control characters are printed in a columnar format. 502.It Cm everything 503Same as 504.Cm all . 505.It Cm cooked 506Same as 507.Cm sane . 508.It Cm cbreak 509If set, enables 510.Cm brkint , ixon , imaxbel , opost , 511.Cm isig , iexten , 512and 513.Cm Fl icanon . 514If unset, same as 515.Cm sane . 516.It Cm new 517Same as 518.Cm tty . 519.It Cm old 520Same as 521.Cm tty . 522.It Cm newcrt Pq Fl newcrt 523Same as 524.Cm crt . 525.It Cm pass8 526The converse of 527.Cm parity . 528.It Cm tandem Pq Fl tandem 529Same as 530.Cm ixoff . 531.It Cm decctlq Pq Fl decctlq 532The converse of 533.Cm ixany . 534.It Cm crterase Pq Fl crterase 535Same as 536.Cm echoe . 537.It Cm crtbs Pq Fl crtbs 538Same as 539.Cm echoe . 540.It Cm crtkill Pq Fl crtkill 541Same as 542.Cm echoke . 543.It Cm ctlecho Pq Fl ctlecho 544Same as 545.Cm echoctl . 546.It Cm prterase Pq Fl prterase 547Same as 548.Cm echoprt . 549.It Cm litout Pq Fl litout 550The converse of 551.Cm opost . 552.It Cm tabs Pq Fl tabs 553The converse of 554.Cm oxtabs . 555.It Cm brk Ar value 556Same as the control character 557.Cm eol . 558.It Cm flush Ar value 559Same as the control character 560.Cm discard . 561.It Cm rprnt Ar value 562Same as the control character 563.Cm reprint . 564.El 565.Pp 566The 567.Nm stty 568utility exits with a value of 0 if successful, and >0 if an error occurs. 569.Sh SEE ALSO 570.Xr termios 4 571.Sh STANDARDS 572The 573.Nm stty 574function is expected to be 575.St -p1003.2 576compatible. The flags 577.Fl e 578and 579.Fl f 580are 581extensions to the standard. 582