1.\" $OpenBSD: stty.1,v 1.49 2022/03/31 17:27:14 naddy 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: March 31 2022 $ 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 | e | 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. 64.It Fl e 65Display all the current settings for the terminal to standard output 66in the traditional 67.Bx 68.Dq all 69and 70.Dq everything 71formats. 72.It Fl f Ar file 73Open and use the terminal named by 74.Ar file 75rather than using standard input. 76The file is opened using the 77.Dv O_NONBLOCK 78flag of 79.Xr open 2 , 80making it possible to 81set or display settings on a terminal that might otherwise 82block on the open. 83.It Fl g 84Display all the current settings for the terminal to standard output 85in a form that may be used as an argument to a subsequent invocation of 86.Nm 87to restore the current terminal state. 88The output does not contain any characters that require quoting, 89to avoid word expansion by the shell. 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.Li c_cflag 99in the termios structure. 100.Bl -tag -width Ds 101.It Cm parenb Pq Fl parenb 102Enable (disable) parity generation 103and detection. 104.It Cm parodd Pq Fl parodd 105Select odd (even) parity. 106.It Cm cs5 cs6 cs7 cs8 107Select character size, if possible. 108.It Ar number 109Set terminal baud rate to the 110number given, if possible. 111If the 112baud rate is set to zero, modem 113control is no longer 114asserted. 115.It Cm ispeed Ar number 116Set terminal input baud rate to the 117number given, if possible. 118If the 119input baud rate is set to zero, the 120input baud rate is set to the 121value of the output baud 122rate. 123.It Cm ospeed Ar number 124Set terminal output baud rate to 125the number given, if possible. 126If 127the output baud rate is set to 128zero, modem control is 129no longer asserted. 130.It Cm speed Ar number 131This sets both 132.Cm ispeed 133and 134.Cm ospeed 135to 136.Ar number . 137.It Cm hupcl Pq Fl hupcl 138Stop asserting modem control 139(do not stop asserting modem control) on last close. 140.It Cm hup Pq Fl hup 141Same as 142.Cm hupcl 143.Pq Fl hupcl . 144.It Cm cstopb Pq Fl cstopb 145Use two (one) stop bits per character. 146.It Cm cread Pq Fl cread 147Enable (disable) the receiver. 148.It Cm clocal Pq Fl clocal 149Assume a line without (with) modem 150control. 151.It Cm crtscts Pq Fl crtscts 152Enable (disable) RTS/CTS flow control. 153.El 154.Ss Input modes 155This corresponds to the 156.Li c_iflag 157in the termios structure. 158.Bl -tag -width Ds 159.It Cm ignbrk Pq Fl ignbrk 160Ignore (do not ignore) break on 161input. 162.It Cm brkint Pq Fl brkint 163Signal (do not signal) 164.Dv INTR 165on 166break. 167.It Cm ignpar Pq Fl ignpar 168Ignore (do not ignore) parity 169errors. 170.It Cm parmrk Pq Fl parmrk 171Mark (do not mark) parity errors. 172.It Cm inpck Pq Fl inpck 173Enable (disable) input parity 174checking. 175.It Cm istrip Pq Fl istrip 176Strip (do not strip) input characters 177to seven bits. 178.It Cm inlcr Pq Fl inlcr 179Map (do not map) 180.Dv NL 181to 182.Dv CR 183on input. 184.It Cm igncr Pq Fl igncr 185Ignore (do not ignore) 186.Dv CR 187on input. 188.It Cm icrnl Pq Fl icrnl 189Map (do not map) 190.Dv CR 191to 192.Dv NL 193on input. 194.It Cm iuclc Pq Fl iuclc 195Translate (do not translate) upper case to lower case 196on input. 197.It Cm ixon Pq Fl ixon 198Enable (disable) 199.Dv START/STOP 200output 201control. 202Output from the system is 203stopped when the system receives 204.Dv STOP 205and started when the system 206receives 207.Dv START , 208or if 209.Cm ixany 210is set, any character restarts output. 211.It Cm ixoff Pq Fl ixoff 212Request that the system send (not 213send) 214.Dv START/STOP 215characters when 216the input queue is nearly 217empty/full. 218.It Cm ixany Pq Fl ixany 219Allow any character (allow only 220.Dv START ) 221to restart output. 222.It Cm imaxbel Pq Fl imaxbel 223The system imposes a limit of 224.Dv MAX_INPUT 225(currently 255) characters in the input queue. 226If 227.Cm imaxbel 228is set and the input queue limit has been reached, 229subsequent input causes the system to send an ASCII BEL 230character to the output queue (the terminal beeps at you). 231Otherwise, if 232.Cm imaxbel 233is unset and the input queue is full, the next input character causes 234the entire input and output queues to be discarded. 235.El 236.Ss Output modes 237This corresponds to the 238.Li c_oflag 239of the termios structure. 240.Bl -tag -width Ds 241.It Cm opost Pq Fl opost 242Post-process output (do not 243post-process output; ignore all other 244output modes). 245.It Cm onlcr Pq Fl onlcr 246Map (do not map) 247.Dv NL 248to 249.Dv CR-NL 250on output. 251.It Cm ocrnl Pq Fl ocrnl 252Translate (do not translate) carriage return to newline on output. 253.It Cm onocr Pq Fl onocr 254Carriage return is not output (is output) at column 0. 255.It Cm onlret Pq Fl onlret 256Newline performs (does not perform) carriage return on output. 257.It Cm olcuc Pq Fl olcuc 258Translate (do not translate) lower case to upper case on output. 259.It Cm oxtabs Pq Fl oxtabs 260Expand (do not expand) tabs to spaces on output. 261.It Cm onoeot Pq Fl onoeot 262Discard (do not discard) EOFs on output. 263.El 264.Ss Local modes 265Local mode flags (lflags) affect various and sundry characteristics of terminal 266processing. 267Historically the term "local" pertained to new job control features 268implemented by Jim Kulp on a PDP 11/70 at IIASA. 269Later the driver ran on the first VAX at Evans Hall, UC Berkeley, 270where the job control details were greatly modified 271but the structure definitions and names remained essentially unchanged. 272The second interpretation of the 273.Sq l 274in lflag is 275.Dq line discipline flag 276which corresponds to the 277.Li c_lflag 278of the termios structure. 279.Bl -tag -width Ds 280.It Cm isig Pq Fl isig 281Enable (disable) the checking of 282characters against the special control 283characters 284.Dv INTR , QUIT , 285and 286.Dv SUSP . 287.It Cm icanon Pq Fl icanon 288Enable (disable) canonical input 289.Pf ( Dv ERASE 290and 291.Dv KILL 292processing). 293.It Cm iexten Pq Fl iexten 294Enable (disable) any implementation 295defined special control characters 296not currently controlled by 297.Cm icanon , 298.Cm isig , 299or 300.Cm ixon . 301.It Cm echo Pq Fl echo 302Echo back (do not echo back) every 303character typed. 304.It Cm echoe Pq Fl echoe 305The 306.Dv ERASE 307character shall (shall 308not) visually erase the last character 309in the current line from the 310display, if possible. 311.It Cm echok Pq Fl echok 312Echo (do not echo) 313.Dv NL 314after 315.Dv KILL 316character. 317.It Cm echoke Pq Fl echoke 318The 319.Dv KILL 320character shall (shall 321not) visually erase the 322current line from the 323display, if possible. 324.It Cm echonl Pq Fl echonl 325Echo (do not echo) 326.Dv NL , 327even if echo 328is disabled. 329.It Cm echoctl Pq Fl echoctl 330If 331.Cm echoctl 332is set, echo control characters as 333.Ql ^X . 334Otherwise control characters echo as themselves. 335.It Cm echoprt Pq Fl echoprt 336For printing terminals. 337If set, echo erased characters backwards within 338.Ql \e 339and 340.Ql / . 341Otherwise, disable this feature. 342.It Cm noflsh Pq Fl noflsh 343Disable (enable) flush after 344.Dv INTR , QUIT , SUSP . 345.It Cm tostop Pq Fl tostop 346Send (do not send) 347.Dv SIGTTOU 348for background output. 349This causes background jobs to stop if they attempt 350terminal output. 351.It Cm altwerase Pq Fl altwerase 352Use (do not use) an alternate word erase algorithm when processing 353.Dv WERASE 354characters. 355This alternate algorithm considers sequences of 356alphanumeric/underscores as words. 357It also skips the first preceding character in its classification 358(as a convenience since the one preceding character could have been 359erased with simply an 360.Dv ERASE 361character). 362.It Cm mdmbuf Pq Fl mdmbuf 363If set, flow control output based on condition of Carrier Detect. 364Otherwise 365writes return an error if Carrier Detect is low (and Carrier is not being 366ignored with the 367.Dv CLOCAL 368flag). 369.It Cm flusho Pq Fl flusho 370Indicates output is (is not) being discarded. 371.It Cm pendin Pq Fl pendin 372Indicates input is (is not) pending after a switch from non-canonical 373to canonical mode and will be re-input when a read becomes pending 374or more input arrives. 375.It Cm xcase Pq Fl xcase 376Upper and lower case is (is not) handled canonically on input and output 377with 378.Cm iuclc 379and 380.Cm olcuc . 381.El 382.Ss Control characters 383.Bl -tag -width Ds -compact 384.It Ar control-character Ar string 385Set 386.Ar control-character 387to 388.Ar string . 389If string is a single character, 390the control character is set to 391that character. 392If string is the 393two character sequence 394.Ql ^- 395or the string 396.Dq undef , 397the control character 398is disabled (i.e. set to 399.Brq Dv _POSIX_VDISABLE ) . 400.Pp 401Recognized control-characters: 402.Bl -column "character" "Subscript" "Description" 403.It Sy Control Ta Sy Subscript Ta Sy Description 404.It Sy character Ta "" Ta "" 405.It eof Ta Dv VEOF Ta "EOF character" 406.It eol Ta Dv VEOL Ta "EOL character" 407.It eol2 Ta Dv VEOL2 Ta "EOL2 character" 408.It erase Ta Dv VERASE Ta "ERASE character" 409.It werase Ta Dv VWERASE Ta "WERASE character" 410.It intr Ta Dv VINTR Ta "INTR character" 411.It kill Ta Dv VKILL Ta "KILL character" 412.It quit Ta Dv VQUIT Ta "QUIT character" 413.It susp Ta Dv VSUSP Ta "SUSP character" 414.It start Ta Dv VSTART Ta "START character" 415.It stop Ta Dv VSTOP Ta "STOP character" 416.It dsusp Ta Dv VDSUSP Ta "DSUSP character" 417.It lnext Ta Dv VLNEXT Ta "LNEXT character" 418.It reprint Ta Dv VREPRINT Ta "REPRINT character" 419.It status Ta Dv VSTATUS Ta "STATUS character" 420.El 421.Pp 422.It Cm min Ar number 423.It Cm time Ar number 424Set the value of 425.Cm min 426or 427.Cm time 428to 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 Ds 439.It Ar saved settings 440Set the current terminal 441characteristics to the saved settings 442produced by the 443.Fl g 444option. 445.It Cm evenp No or Cm parity 446Enable 447.Cm parenb 448and 449.Cm cs7 ; 450disable 451.Cm parodd . 452.It Cm oddp 453Enable 454.Cm parenb , 455.Cm cs7 , 456and 457.Cm parodd . 458.It Fl parity , evenp , oddp 459Disable 460.Cm parenb 461and set 462.Cm cs8 . 463.It Cm \&nl Pq Fl \&nl 464Enable (disable) 465.Cm icrnl . 466In addition, 467.Fl \&nl 468unsets 469.Cm inlcr 470and 471.Cm igncr . 472.It Cm ek 473Reset 474.Dv ERASE 475and 476.Dv KILL 477characters 478back to system defaults. 479.It Cm sane 480Resets all modes to reasonable values for interactive terminal use. 481.It Cm tty 482Set the line discipline to the standard terminal line discipline 483.Dv TTYDISC . 484.It Cm crt Pq Fl crt 485Set (disable) all modes suitable for a CRT display device. 486.It Cm kerninfo Pq Fl kerninfo 487Enable (disable) the system generated status line associated with 488processing a 489.Dv STATUS 490character (usually set to 491.Ql ^T ) . 492The status line consists of the 493system load average, the current command name, its process ID, the 494event the process is waiting on (or the status of the process), the user 495and system times, percent CPU, and current memory usage. 496.It Cm columns Ar number 497The terminal size is recorded as having 498.Ar number 499columns. 500.It Cm cols Ar number 501This is an alias for 502.Cm columns . 503.It Cm rows Ar number 504The terminal size is recorded as having 505.Ar number 506rows. 507.It Cm dec 508Set modes suitable for users of Digital Equipment Corporation systems 509.Pf ( Dv ERASE , 510.Dv KILL , 511and 512.Dv INTR 513characters are set to ^?, ^U, and ^C; 514.Dv ixany 515is disabled, and 516.Dv crt 517is enabled). 518.It Cm extproc Pq Fl extproc 519If set, this flag indicates that some amount of terminal processing is being 520performed by either the terminal hardware or by the remote side connected 521to a pty. 522.It Cm raw Pq Fl raw 523If set, change the modes of the terminal so that no input or output processing 524is performed. 525If unset, change the modes of the terminal to some reasonable 526state that performs input and output processing. 527Note that since the terminal driver no longer has a single 528.Dv RAW 529bit, it is not possible to intuit what flags were set prior to setting 530.Cm raw . 531This means that unsetting 532.Cm raw 533may not put back all the setting that were previously in effect. 534To set the terminal into a raw state and then accurately restore it, 535the following shell code is recommended: 536.Bd -literal -offset indent 537save_state=$(stty -g) 538stty raw 539\&... 540stty "$save_state" 541.Ed 542.It Cm size 543The size of the terminal is printed as two numbers on a single line, 544first rows, then columns. 545.El 546.Ss Compatibility modes 547These modes remain for compatibility with the previous version of 548the stty command. 549.Bl -tag -width Ds 550.It Cm all 551Reports all the terminal modes as with 552.Cm stty Fl a 553except that the control characters are printed in a columnar format. 554.It Cm everything 555Same as 556.Cm all . 557.It Cm cooked 558Same as 559.Cm sane . 560.It Cm cbreak 561If set, enables 562.Cm brkint , ixon , imaxbel , opost , 563.Cm isig , iexten , 564and 565.Fl icanon . 566If unset, same as 567.Cm sane . 568.It Cm new 569Same as 570.Cm tty . 571.It Cm old 572Same as 573.Cm tty . 574.It Cm newcrt Pq Fl newcrt 575Same as 576.Cm crt . 577.It Cm pass8 578The converse of 579.Cm parity . 580.It Cm tandem Pq Fl tandem 581Same as 582.Cm ixoff . 583.It Cm decctlq Pq Fl decctlq 584The converse of 585.Cm ixany . 586.It Cm crterase Pq Fl crterase 587Same as 588.Cm echoe . 589.It Cm crtbs Pq Fl crtbs 590Same as 591.Cm echoe . 592.It Cm crtkill Pq Fl crtkill 593Same as 594.Cm echoke . 595.It Cm ctlecho Pq Fl ctlecho 596Same as 597.Cm echoctl . 598.It Cm prterase Pq Fl prterase 599Same as 600.Cm echoprt . 601.It Cm lcase Pq Fl lcase 602Same as 603.Cm iuclc , 604.Cm olcuc 605and 606.Cm xcase . 607.It Cm litout Pq Fl litout 608The converse of 609.Cm opost . 610.It Cm tabs Pq Fl tabs 611The converse of 612.Cm oxtabs . 613.It Cm brk Ar value 614Same as the control character 615.Cm eol . 616.It Cm flush Ar value 617Same as the control character 618.Cm discard . 619.It Cm rprnt Ar value 620Same as the control character 621.Cm reprint . 622.El 623.Ss Control operations 624These operations are not modes, but rather commands to be performed by 625the tty layer. 626.Bl -tag -width Ds 627.It Cm ostart 628Performs a 629.Dq start output 630operation, as normally done by an 631incoming 632.Dv START 633character when 634.Cm ixon 635is set. 636.It Cm ostop 637Performs a 638.Dq stop output 639operation, as normally done by an incoming 640.Dv STOP 641character when 642.Cm ixon 643is set. 644.El 645.Sh EXIT STATUS 646.Ex -std stty 647.Sh SEE ALSO 648.Xr termios 4 , 649.Xr tty 4 650.Sh STANDARDS 651The 652.Nm 653utility is compliant with the 654.St -p1003.1-2008 655specification. 656.Pp 657The flags 658.Op Fl ef , 659the operands 660.Cm altwerase , 661.Cm cols , 662.Cm columns , 663.Cm crt , 664.Cm crtscts , 665.Cm dec , 666.Cm echoke , 667.Cm extproc , 668.Cm flusho , 669.Cm imaxbel , 670.Cm kerninfo , 671.Cm mdmbuf , 672.Cm onlcr , 673.Cm onoeot , 674.Cm ostart , 675.Cm ostop , 676.Cm oxtabs , 677.Cm pendin , 678.Cm rows , 679.Cm size , 680.Cm speed , 681and 682.Cm tty , 683and the control characters 684eol2, 685dsusp, 686lnext, 687reprint, 688status, 689and 690werase 691are all extensions to that specification. 692.Pp 693The operands 694.Cm iuclc , 695.Cm olcuc , 696and 697.Cm xcase 698are marked by 699.St -p1003.1-2008 700as legacy items; 701the operands listed in 702.Sx Compatibility modes 703can also be considered legacy. 704.Pp 705The operands 706.Cm bs0-1 , 707.Cm cr0-3 , 708.Cm ff0-1 , 709.Cm nl0-1 , 710.Cm ocrnl , 711.Cm ofdel , 712.Cm ofill , 713.Cm onlret , 714.Cm onocr , 715.Cm raw , 716.Cm tab0-3 , 717.Cm tabs , 718and 719.Cm vt0-1 720are marked by 721.St -p1003.1-2008 722as being an X/Open System Interfaces option. 723Of those, only 724.Cm ocrnl , 725.Cm onlret , 726.Cm onocr , 727.Cm raw , 728and 729.Cm tabs 730are supported by this implementation of 731.Nm , 732and behaviour for 733.Cm tabs 734differs. 735.Sh HISTORY 736A 737.Nm 738command appeared in 739.At v2 . 740