1.\" Copyright (c) 1990 The Regents of the University of California. 2.\" 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 6.19 (Berkeley) 12/16/92 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 (not 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. This alternate algorithm considers sequences of 303alphameric/underscores as words. It also skips the first preceding character 304in its classification (as a convenience since the one preceding character 305could have been erased with simply an 306.Dv ERASE 307character.) 308.It Cm mdmbuf Pq Fl mdmbuf 309If set, flow control output based on condition of Carrier Detect. Otherwise 310writes return an error if Carrier Detect is low (and Carrier is not being 311ignored with the 312.Dv CLOCAL 313flag.) 314.It Cm flusho Pq Fl flusho 315Indicates output is (is not) being discarded. 316.It Cm pendin Pq Fl pendin 317Indicates input is (is not) pending after a switch from non-canonical 318to canonical mode and will be re-input when a read becomes pending 319or more input arrives. 320.El 321.Ss Control Characters: 322.Bl -tag -width Fl 323.It Ar control-character Ar string 324Set 325.Ar control-character 326to 327.Ar string . 328If string is a single character, 329the control character is set to 330that character. 331If string is the 332two character sequence "^-" or the 333string "undef" the control character 334is disabled (i.e. set to 335.Pf { Dv _POSIX_VDISABLE Ns } . ) 336.Pp 337Recognized control-characters: 338.Bd -ragged -offset indent 339.Bl -column character Subscript 340.It control- 341.It character Subscript Description 342.It _________ _________ _______________ 343.It eof Ta Tn VEOF EOF No character 344.It eol Ta Tn VEOL EOL No character 345.It eol2 Ta Tn VEOL2 EOL2 No character 346.It erase Ta Tn VERASE ERASE No character 347.It werase Ta Tn VWERASE WERASE No character 348.It intr Ta Tn VINTR INTR No character 349.It kill Ta Tn VKILL KILL No character 350.It quit Ta Tn VQUIT QUIT No character 351.It susp Ta Tn VSUSP SUSP No character 352.It start Ta Tn VSTART START No character 353.It stop Ta Tn VSTOP STOP No character 354.It dsusp Ta Tn VDSUSP DSUSP No character 355.It lnext Ta Tn VLNEXT LNEXT No character 356.It reprint Ta Tn VREPRINT REPRINT No character 357.It status Ta Tn VSTATUS STATUS No character 358.El 359.Ed 360.It Cm min Ar number 361.It Cm time Ar number 362Set the value of min or time to 363number. 364.Dv MIN 365and 366.Dv TIME 367are used in 368Non-Canonical mode input processing 369(-icanon). 370.El 371.Ss Combination Modes: 372.Pp 373.Bl -tag -width Fl 374.It Ar saved settings 375Set the current terminal 376characteristics to the saved settings 377produced by the 378.Fl g 379option. 380.It Cm evenp No or Cm parity 381Enable parenb and cs7; disable 382parodd. 383.It Cm oddp 384Enable parenb, cs7, and parodd. 385.It Fl parity , evenp , oddp 386Disable parenb, and set cs8. 387.It Cm \&nl Pq Fl \&nl 388Enable (disable) icrnl. 389In addition 390-nl unsets inlcr and igncr. 391.It Cm ek 392Reset 393.Dv ERASE 394and 395.Dv KILL 396characters 397back to system defaults. 398.It Cm sane 399Resets all modes to reasonable values for interactive terminal use. 400.It Cm tty 401Set the line discipline to the standard terminal line discipline 402.Dv TTYDISC . 403.It Cm crt Pq Fl crt 404Set (disable) all modes suitable for a CRT display device. 405.It Cm kerninfo Pq Fl kerninfo 406Enable (disable) the system generated status line associated with 407processing a 408.Dv STATUS 409character (usually set to ^T). The status line consists of the 410system load average, the current command name, its process ID, the 411event the process is waiting on (or the status of the process), the user 412and system times, percent cpu, and current memory usage. 413.It Cm columns Ar number 414The terminal size is recorded as having 415.Ar number 416columns. 417.It Cm cols Ar number 418is an alias for 419.Cm columns. 420.It Cm rows Ar number 421The terminal size is recorded as having 422.Ar number 423rows. 424.It Cm dec 425Set modes suitable for users of Digital Equipment Corporation systems ( 426.Dv ERASE , 427.Dv KILL , 428and 429.Dv INTR 430characters are set to ^?, ^U, and ^C; 431.Dv ixany 432is disabled, and 433.Dv crt 434is enabled.) 435.It Cm extproc Pq Fl extproc 436If set, this flag indicates that some amount of terminal processing is being 437performed by either the terminal hardware or by the remote side connected 438to a pty. 439.It Cm raw Pq Fl raw 440If set, change the modes of the terminal so that no input or output processing 441is performed. If unset, change the modes of the terminal to some reasonable 442state that performs input and output processing. Note that since the 443terminal driver no longer has a single 444.Dv RAW 445bit, it is not possible to intuit what flags were set prior to setting 446.Cm raw . 447This means that unsetting 448.Cm raw 449may not put back all the setting that were previously in effect. 450To set the terminal into a raw state and then accurately restore it, the following 451shell code is recommended: 452.nf 453 454save_state=$(stty -g) 455stty raw 456\&... 457stty "$save_state" 458 459.fi 460.It Cm size 461The size of the terminal is printed as two numbers on a single line, 462first rows, then columns. 463.El 464.Ss Compatability Modes: 465.Pp 466These modes remain for compatability with the previous version of 467the stty command. 468.Bl -tag -width Fl 469.It Cm all 470Reports all the terminal modes as with 471.Cm stty Fl a 472except that the control characters are printed in a columnar format. 473.It Cm everything 474Same as 475.Cm all . 476.It Cm cooked 477Same as 478.Cm sane . 479.It Cm cbreak 480If set, enables 481.Cm brkint , ixon , imaxbel , opost , 482.Cm isig , iexten , 483and 484.Cm Fl icanon . 485If unset, same as 486.Cm sane . 487.It Cm new 488Same as 489.Cm tty . 490.It Cm old 491Same as 492.Cm tty . 493.It Cm newcrt Pq Fl newcrt 494Same as 495.Cm crt . 496.It Cm pass8 497The converse of 498.Cm parity . 499.It Cm tandem Pq Fl tandem 500Same as 501.Cm ixoff . 502.It Cm decctlq Pq Fl decctlq 503The converse of 504.Cm ixany . 505.It Cm crterase Pq Fl crterase 506Same as 507.Cm echoe . 508.It Cm crtbs Pq Fl crtbs 509Same as 510.Cm echoe . 511.It Cm crtkill Pq Fl crtkill 512Same as 513.Cm echoke . 514.It Cm ctlecho Pq Fl ctlecho 515Same as 516.Cm echoctl . 517.It Cm prterase Pq Fl prterase 518Same as 519.Cm echoprt . 520.It Cm litout Pq Fl litout 521The converse of 522.Cm opost . 523.It Cm tabs Pq Fl tabs 524The converse of 525.Cm tabs . 526.It Cm brk Ar value 527Same as the control character 528.Cm eol . 529.It Cm flush Ar value 530Same as the control character 531.Cm discard . 532.It Cm rprnt Ar value 533Same as the control character 534.Cm reprint . 535.El 536.Pp 537The 538.Nm stty 539utility exits with a value of 0 if successful, and >0 if an error occurs. 540.Sh SEE ALSO 541.Xr termios 4 542.Sh STANDARDS 543The 544.Nm stty 545function is expected to be 546.St -p1003.2 547compatible. The flags 548.Fl e 549and 550.Fl f 551are 552extensions to the standard. 553