1.\" $NetBSD: stty.1,v 1.41 2012/06/20 14:19:39 wiz 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 June 16, 2012 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. 118.It Cm ispeed Ar number 119Set terminal input baud rate to 120.Ar number , 121if possible. 122If the 123input baud rate is set to zero, the 124input baud rate is set to the 125value of the output baud 126rate. 127.It Cm ospeed Ar number 128Set terminal output baud rate to 129.Ar number , 130if possible. 131If 132the output baud rate is set to 133zero, modem control is 134no longer asserted. 135.It Cm speed Ar number 136This sets both 137.Cm ispeed 138and 139.Cm ospeed 140to 141.Ar number . 142.It Cm hupcl Pq Fl hupcl 143Stop asserting modem control 144(do not stop asserting modem control) on last close. 145.It Cm hup Pq Fl hup 146Same as hupcl 147.Pq Fl hupcl . 148.It Cm cstopb Pq Fl cstopb 149Use two (one) stop bits per character. 150.It Cm cread Pq Fl cread 151Enable (disable) the receiver. 152.It Cm clocal Pq Fl clocal 153Assume a line without (with) modem 154control. 155.It Cm crtscts Pq Fl crtscts 156Enable RTS/CTS flow control. 157.It Cm cdtrcts Pq Fl cdtrcts 158Enable DTR/CTS flow control (if supported). 159.El 160.Ss Input Modes 161This corresponds to the 162.Fa c_iflag 163of the 164.Xr termios 4 165structure. 166.Bl -tag -width Fl 167.It Cm ignbrk Pq Fl ignbrk 168Ignore (do not ignore) break on 169input. 170.It Cm brkint Pq Fl brkint 171Signal (do not signal) 172.Dv INTR 173on 174break. 175.It Cm ignpar Pq Fl ignpar 176Ignore (do not ignore) parity 177errors. 178.It Cm parmrk Pq Fl parmrk 179Mark (do not mark) parity errors. 180.It Cm inpck Pq Fl inpck 181Enable (disable) input parity 182checking. 183.It Cm istrip Pq Fl istrip 184Strip (do not strip) input characters 185to seven bits. 186.It Cm inlcr Pq Fl inlcr 187Map (do not map) 188.Dv NL 189to 190.Dv CR 191on input. 192.It Cm igncr Pq Fl igncr 193Ignore (do not ignore) 194.Dv CR 195on input. 196.It Cm icrnl Pq Fl icrnl 197Map (do not map) 198.Dv CR 199to 200.Dv NL 201on input. 202.It Cm ixon Pq Fl ixon 203Enable (disable) 204.Dv START/STOP 205output 206control. 207Output from the system is 208stopped when the system receives 209.Dv STOP 210and started when the system 211receives 212.Dv START , 213or if 214.Cm ixany 215is set, any character restarts output. 216.It Cm ixoff Pq Fl ixoff 217Request that the system send (not 218send) 219.Dv START/STOP 220characters when 221the input queue is nearly 222empty/full. 223.It Cm ixany Pq Fl ixany 224Allow any character (allow only 225.Dv START ) 226to restart output. 227.It Cm imaxbel Pq Fl imaxbel 228The system imposes a limit of 229.Dv MAX_INPUT 230(currently 255) characters in the input queue. 231If 232.Cm imaxbel 233is set and the input queue limit has been reached, 234subsequent input causes the system to send an ASCII BEL 235character to the output queue (the terminal beeps at you). 236Otherwise, 237if 238.Cm imaxbel 239is unset and the input queue is full, the next input character causes 240the entire input and output queues to be discarded. 241.El 242.Ss Output Modes 243This corresponds to the 244.Fa c_oflag 245of the 246.Xr termios 4 247structure. 248.Bl -tag -width Fl 249.It Cm opost Pq Fl opost 250Post-process output (do not 251post-process output; ignore all other 252output modes). 253.It Cm onlcr Pq Fl onlcr 254Map (do not map) 255.Dv NL 256to 257.Dv CR-NL 258on output. 259.It Cm ocrnl Pq Fl ocrnl 260Map (do not map) 261.Dv CR 262to 263.Dv NL 264on output. 265.It Cm oxtabs Pq Fl oxtabs 266Expand (do not expand) tabs to spaces on output. 267.It Cm onocr Pq Fl onocr 268Do not (do) output CRs at column zero. 269.It Cm onlret Pq Fl onlret 270On the terminal NL performs (does not perform) the CR function. 271.El 272.Ss Local Modes 273Local mode flags (lflags) affect various and sundry characteristics of terminal 274processing. 275Historically the term "local" pertained to new job control features 276implemented by Jim Kulp on a 277.Tn PDP Ns -11/70 278at 279.Tn IIASA . 280Later the driver ran on the first 281.Tn VAX 282at Evans Hall, UC Berkeley, where the job control details 283were greatly modified but the structure definitions and names 284remained essentially unchanged. 285The second interpretation of the 286.Sq l 287in lflag 288is 289.Dq line discipline flag , 290which corresponds to the 291.Fa c_lflag 292of the 293.Xr termios 4 294structure. 295.Bl -tag -width Fl 296.It Cm isig Pq Fl isig 297Enable (disable) the checking of 298characters against the special control 299characters 300.Dv INTR , QUIT , 301and 302.Dv SUSP . 303.It Cm icanon Pq Fl icanon 304Enable (disable) canonical input 305.Dv ( ERASE 306and 307.Dv KILL 308processing). 309.It Cm iexten Pq Fl iexten 310Enable (disable) any implementation 311defined special control characters 312not currently controlled by icanon, 313isig, or ixon. 314.It Cm echo Pq Fl echo 315Echo back (do not echo back) every 316character typed. 317.It Cm echoe Pq Fl echoe 318The 319.Dv ERASE 320character shall (shall 321not) visually erase the last character 322in the current line from the 323display, if possible. 324.It Cm echok Pq Fl echok 325Echo (do not echo) 326.Dv NL 327after 328.Dv KILL 329character. 330.It Cm echoke Pq Fl echoke 331The 332.Dv KILL 333character shall (shall 334not) visually erase 335the current line from the 336display, if possible. 337.It Cm echonl Pq Fl echonl 338Echo (do not echo) 339.Dv NL , 340even if echo 341is disabled. 342.It Cm echoctl Pq Fl echoctl 343If 344.Cm echoctl 345is set, echo control characters as ^X. 346Otherwise control characters echo as themselves. 347.It Cm echoprt Pq Fl echoprt 348For printing terminals. 349If set, echo erased characters backwards within 350.Dq \e 351and 352.Dq / . 353Otherwise, disable this feature. 354.It Cm noflsh Pq Fl noflsh 355Disable (enable) flush after 356.Dv INTR , QUIT , SUSP . 357.It Cm tostop Pq Fl tostop 358Send (do not send) 359.Dv SIGTTOU 360for background output. 361This causes background jobs to stop if they attempt terminal output. 362.It Cm altwerase Pq Fl altwerase 363Use (do not use) an alternative word erase algorithm when processing 364.Dv WERASE 365characters. 366This alternative algorithm considers sequences of 367alphanumeric/underscores as words. 368It also skips the first preceding character in its classification 369(as a convenience since the one preceding character could have been 370erased with simply an 371.Dv ERASE 372character). 373.It Cm mdmbuf Pq Fl mdmbuf 374If set, flow control output based on condition of Carrier Detect. 375Otherwise writes return an error if Carrier Detect is low (and Carrier 376is not being ignored with the 377.Dv CLOCAL 378flag). 379.It Cm flusho Pq Fl flusho 380Indicates output is (is not) being discarded. 381.It Cm pendin Pq Fl pendin 382Indicates input is (is not) pending after a switch from non-canonical 383to canonical mode and will be re-input when a read becomes pending 384or more input arrives. 385.El 386.Ss Control Characters 387.Bl -tag -width Fl 388.It Ar control-character Ar string 389Set 390.Ar control-character 391to string 392.Ar string . 393If the string is a single character, 394then the control character is set to 395that character. 396If the string is the 397two character sequence "^-" or the 398string "undef", then the control character 399is disabled (i.e., set to 400.Bro Dv _POSIX_VDISABLE Brc ) . 401.Pp 402Recognized control characters: 403.Bd -ragged -offset indent 404.Bl -column character Subscript Description 405.It control- Ta "" Ta "" 406.It character Subscript Description 407.It _________ _________ _______________ 408.It eof Ta Tn VEOF Ta EOF No character 409.It eol Ta Tn VEOL Ta EOL No character 410.It eol2 Ta Tn VEOL2 Ta EOL2 No character 411.It erase Ta Tn VERASE Ta ERASE No character 412.It werase Ta Tn VWERASE Ta WERASE No character 413.It kill Ta Tn VKILL Ta KILL No character 414.It reprint Ta Tn VREPRINT Ta REPRINT No character 415.It intr Ta Tn VINTR Ta INTR No character 416.It quit Ta Tn VQUIT Ta QUIT No character 417.It susp Ta Tn VSUSP Ta SUSP No character 418.It dsusp Ta Tn VDSUSP Ta DSUSP No character 419.It start Ta Tn VSTART Ta START No character 420.It stop Ta Tn VSTOP Ta STOP No character 421.It lnext Ta Tn VLNEXT Ta LNEXT No character 422.It status Ta Tn VSTATUS Ta STATUS No character 423.It discard Ta Tn VDISCARD Ta DISCARD No character 424.El 425.Ed 426.It Cm min Ar number 427.It Cm time Ar number 428Set the value of min or time to 429.Ar number . 430.Dv MIN 431and 432.Dv TIME 433are used in 434Non-Canonical mode input processing 435(-icanon). 436.El 437.Ss Combination Modes 438.Bl -tag -width Fl 439.It Ar saved settings 440Set the current terminal characteristics to the saved settings 441produced by the 442.Fl g 443option. 444.It Cm evenp No or Cm parity 445Enable parenb and cs7; disable parodd. 446.It Cm oddp 447Enable parenb, cs7, and parodd. 448.It Fl parity , evenp , oddp 449Disable parenb, and set cs8. 450.It Cm \&nl Pq Fl \&nl 451Enable (disable) icrnl. 452In addition 453-nl unsets inlcr and igncr. 454.It Cm ek 455Reset 456.Dv ERASE 457and 458.Dv KILL 459characters back to system defaults. 460.It Cm sane 461Resets all modes to reasonable values for interactive terminal use. 462.It Cm insane 463Sets all modes to random values, which are very likely 464.Pq but not guaranteed 465to be unreasonable for interactive terminal use. 466.It Cm tty 467Set the line discipline to the standard terminal line discipline 468.Dv TTYDISC . 469.It Cm crt Pq Fl crt 470Set (disable) all modes suitable for a CRT display device. 471.It Cm kerninfo Pq Fl kerninfo 472Enable (disable) the system generated status line associated with 473processing a 474.Dv STATUS 475character (usually set to ^T). 476The status line consists of the 477system load average, the current command name, its process ID, the 478event the process is waiting on (or the status of the process), the user 479and system times, percent CPU, and current memory usage. 480.It Cm columns Ar number 481The terminal size is recorded as having 482.Ar number 483columns. 484.It Cm cols Ar number 485An alias for 486.Cm columns . 487.It Cm rows Ar number 488The terminal size is recorded as having 489.Ar number 490rows. 491.It Cm dec 492Set modes suitable for users of Digital Equipment Corporation systems 493.Dv ( ERASE , 494.Dv KILL , 495and 496.Dv INTR 497characters are set to ^?, ^U, and ^C; 498.Dv ixany 499is disabled, and 500.Dv crt 501is enabled). 502.It Cm extproc Pq Fl extproc 503If set, this flag indicates that some amount of terminal processing is being 504performed by either the terminal hardware or by the remote side connected 505to a pty. 506.It Cm raw Pq Fl raw 507If set, change the modes of the terminal so that no input or output processing 508is performed. 509If unset, change the modes of the terminal to some reasonable 510state that performs input and output processing. 511Note that since the terminal driver no longer has a single 512.Dv RAW 513bit, it is not possible to intuit what flags were set prior to setting 514.Cm raw . 515This means that unsetting 516.Cm raw 517may not put back all the setting that were previously in effect. 518To set the terminal into a raw state and then accurately restore it, the following 519shell code is recommended: 520.Bd -literal -offset indent 521save_state=$(stty -g) 522stty raw 523\&... 524stty "$save_state" 525.Ed 526.It Cm size 527The size of the terminal is printed as two numbers on a single line, 528first rows, then columns. 529.El 530.Ss Compatibility Modes 531These modes remain for compatibility with the previous version of 532the 533.Nm 534utility. 535.Bl -tag -width Fl 536.It Cm all 537Reports all the terminal modes as with 538.Cm stty Fl a 539except that the control characters are printed in a columnar format. 540.It Cm everything 541Same as 542.Cm all . 543.It Cm cooked 544Same as 545.Cm sane . 546.It Cm cbreak 547If set, enables 548.Cm brkint , ixon , imaxbel , opost , 549.Cm isig , iexten , 550and 551.Fl icanon . 552If unset, same as 553.Cm sane . 554.It Cm new 555Same as 556.Cm tty . 557.It Cm old 558Same as 559.Cm tty . 560.It Cm newcrt Pq Fl newcrt 561Same as 562.Cm crt . 563.It Cm pass8 564The converse of 565.Cm parity . 566.It Cm tandem Pq Fl tandem 567Same as 568.Cm ixoff . 569.It Cm decctlq Pq Fl decctlq 570The converse of 571.Cm ixany . 572.It Cm crterase Pq Fl crterase 573Same as 574.Cm echoe . 575.It Cm crtbs Pq Fl crtbs 576Same as 577.Cm echoe . 578.It Cm crtkill Pq Fl crtkill 579Same as 580.Cm echoke . 581.It Cm ctlecho Pq Fl ctlecho 582Same as 583.Cm echoctl . 584.It Cm prterase Pq Fl prterase 585Same as 586.Cm echoprt . 587.It Cm litout Pq Fl litout 588The converse of 589.Cm opost . 590.It Cm tabs Pq Fl tabs 591The converse of 592.Cm oxtabs . 593.It Cm brk Ar value 594Same as the control character 595.Cm eol . 596.It Cm flush Ar value 597Same as the control character 598.Cm discard . 599.It Cm rprnt Ar value 600Same as the control character 601.Cm reprint . 602.El 603.Ss Control operations 604These operations are not modes, but rather commands to be performed by 605the tty layer. 606.Bl -tag -width Fl 607.It Cm ostart 608Performs a "start output" operation, as normally done by an 609incoming START character when 610.Cm ixon 611is set. 612.It Cm ostop 613Performs a "stop output" operation, as normally done by an 614incoming STOP character when 615.Cm ixon 616is set. 617.El 618.Sh EXIT STATUS 619.Ex -std 620.Sh SEE ALSO 621.Xr termios 4 , 622.Xr tty 4 623.Sh STANDARDS 624The 625.Nm 626utility is expected to be 627.St -p1003.2 628compatible. 629The 630.Fl e 631and 632.Fl f 633flags are 634extensions to the standard, as are the operands mentioned in the control 635operations section. 636