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