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