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