STTY(1) — UNIX Programmer’s Manual
NAME
stty − set or display terminal options
SYNOPSIS
/usr/5bin/stty
/usr/5bin/stty −a
/usr/5bin/stty −g
/usr/5bin/stty option ...
DESCRIPTION
Stty sets options on, or displays current options for, its standard input, which must be a terminal. The command conforms to the X/Open XPG3 definition with the exception of the XPG3 ‘loblk’ option which is not part of the POSIX terminal interface, or relevant to RISC iX, and is hence unsupported. Further options allow control of the kernel extensions to the basic POSIX and X/Open terminal interface, for backwards compatibility with earlier versions of RISC iX, and BSD 4.3.
The original BSD 4.3 style of terminal control is also available, see stty(1). Note however that /usr/5bin/stty itself provides support for all the traditional features of BSD terminal control, and allows finer adjustment of the interface than is possible using /usr/bin/stty.
With no argument, stty reports the speed of the terminal and the values of some frequently referenced options, along with the values of other options which are different from their default. If the flag −a is provided, all available information about the state of the terminal is displayed.
The flag −g by itself causes a single encoded parameter string to be printed on standard output representing the full current state of the terminal in a compact format. Such a string may later be passed as an option to another stty command, and all terminal characteristics will be set as specified in the string. In this way the existing set-up of a terminal can be quickly replicated or reinstated.
Otherwise particular characteristics of the terminal interface are set according to the supplied option string(s), selected from the set below. Options are processed in order of appearance in the argument list − the last occurence of a particular option will be the one which takes effect. Many options are simple boolean items, for which −option is the inverse of option.
Line discipline options
line <linecode>
if <linecode> is a number in the range 0 through 127, attempt to select that line discipline; the system will reject attempts to select unsupported line disciplines, but note that some supported line disciplines are designed for use only with specific special devices and may cause serious difficulties for an interactive user if selected on a normal terminal device. There are three line disciplines which are designed for interactive terminal use; for these, a textual name (rather than a number) may be supplied as the value of <linecode>, as show below.
line old (equivalent to line 0) select the original (V7 UNIX) style of line discipline − this is now little used because of its minimal functionality; in particular it does not support job control
line new select the standard BSD 4.3 style of line discipline, including full job control and other features; this is the default for users of csh(1), and is recommended for general backwards compatibility with earlier versions of RISC iX
line posix select a full POSIX-compliant line discipline, under which extra security checks are applied to some of the control operations specific to the job control facilities. For this reason it may not always be possible to run applications written to work with the original BSD 4.3 job control facilities, or they may behave in an odd way. To enhance security, it is possible for a tty to be locked into the posix line discipline (see description of posixlock below).
posixlock force posix line discipline to remain in force (once set) on the tty until this option is turned off (using −posixlock). This option will only take effect if exercised by the super-user. If the tty is not in posix mode at the time posixlock is set, it may still be switched between other line disciplines by an unprivileged user, up until the time that posix line discipline is set. Thereafter only the super-user may take the tty out of posix mode or clear the posixlock option, even if the tty is closed.
−posixlock
disable posix line discipline locking; this option will only take effect if exercised by the super-user.
Hardware and general control options
parenb enable parity generation and detection in the hardware interface (if supported), i.e. a parity bit will be sent with each transmitted character, and parity information will be extracted from incoming data
−parenb disable hardware parity generation and detection
parodd if parenb is set, the hardware will transmit and expect to receive characters with odd parity
−parodd if parenb is set, the hardware will transmit, and expect to receive, characters with even parity
cs8 cs7 cs6 cs5
set the number of bits of actual data for hardware transmission or reception to 8, 7, 6 or 5 respectively (insofar as the hardware supports this); this setting is independent of the state of parenb
cstopb set the number of stop bits transmitted at the end of each character frame to 2 (normally only used for 110 baud working)
−cstopb set the number of stop bits transmitted as the end of each character frame to 1 (the common setting)
parity composite option equivalent to parenb cs7 −parodd
−parity composite option equivalent to −parenb cs8
evenp composite option equivalent to parenb cs7 −parodd
−evenp composite option equivalent to −parenb cs8
oddp composite option equivalent to parenb cs7 parodd
−oddp composite option equivalent to −parenb −parodd cs7
inpck enable software checking for parity error on input (meaningful only if parenb is also set)
0 if the hardware interface is attached to a modem, cause a disconnection to be performed, i.e. “hang up” the line
50 75 110 134 134.5 150 200 300 600 1200
1800 2400 4800 9600 19200 19.2 38400 38.4
set the baud rate of the serial line interface to the specified value, where 134 is synonymous with 134.5, 19.2 with 19200 and 38.4 with 38400; if the specified baud rate is not supported by the hardware or associated device driver, the command will fail
hupcl
hup when the terminal is closed (e.g. by logout from an interactive session) perform a modem disconnect as for the 0 option
−hupcl
−hup do not perform a modem disconnect when the terminal is closed
clocal for a terminal interface with modem interface capability, ignore the state of the modem control signals on the interface, i.e. treat the line as a purely local connection to a directly attached terminal device
−clocal interpret the modem interface control signals (if supported) so that operations on the terminal will be regulated by e.g. the presence of the carrier signal on a modem line
Input options
ignbrk ignore received line breaks
−ignbrk treat received line breaks according to the settings of brkint and parmrk
brkint if ignbrk is not set, line breaks generate an interrupt (SIGINT) and cause all queued input and output to be discarded
−brkint if ignbrk is not set, received line breaks generate input data as determined by the setting of parmrk
cread enable any input data received at the device to be read by a process having the device open
−cread disable the reception of input data from the terminal; this may be useful if a serial port is being used only for data output (e.g. using a hardcopy terminal as a printer), so that any input received at the hardware interface will be completely ignored and cannot interfere with the processing of output data
istrip incoming characters will be masked to 7 bits before they are read by a process; this is independent of the selected hardware character size
-istrip do not mask incoming characters to 7 bits
inpck enable software checking for parity error on input (meaningful only if parenb is also set)
−inpck disable software checking on input parity; this operates independently of hardware parity, i.e. parenb controls the data format transmitted or received, inpck controls whether parity errors are considered significant
ignpar if parenb and inpck are both set, discard (ignore) incoming characters which are found to have the wrong parity
−ignpar if parenb and inpck are both set, pass characters with the wrong parity through to a process reading from the terminal, in a form determined by the value of parmrk
parmrk if ignbrk and brkint are both unset, pass received line break conditions to a reading process as a sequence of three bytes having values 0377, 0, 0; also, if parenb and inpck are set and ignpar is not set, pass characters received with invalid parity (or with any framing error apart from line break) to a reading process as a sequence of three bytes 0377, 0, X, where X is the value of the erroneous character data supplied by the hardware; in the latter case, if istrip is not set, a valid received character of value 0377 will be passed to the reading process as a two byte sequence 0377, 0377, so as to avoid ambiguity
−parmrk if ignbrk and brkint are both unset, pass received line break conditions to a reading process as a single byte of value 0 (NUL); also, if parenb and inpck are set and ignpar is clear, pass characters received with incorrect parity to a reading process as a single byte of value 0 (NUL)
isig cause signals to be generated by the input of any of the special characters intr, quit, susp and dsusp (dsusp causes signal generation when it is read by a process rather than when it is received)
−isig prevent the generation of signals by any of the special characters which would normally do so
noflsh prevent the flushing of input and output queues which would otherwise take place when receipt of intr, quit and susp causes a signal to be generated
-noflsh flush the input and output queues when receipt of any of intr, quit or susp causes a signal to be generated
echo enable echo of characters as received; the precise way this echoing is done is controlled by the remaining input options, below
−echo no characters are echoed as received, except possibly the newline character, whose echoing is separately controlled by echonl
echonl echo the newline character, even if echo is not set
−echonl newline does not receive special echo treatment
echoe echo the erase character using BS-SP-BS which will cause the preceding character to be wiped out (suitable for use on a video display terminal)
−echoe do not wipe out erased characters
echok when a line is killed with the kill character, echo the character and start a new line
−echok when a line is killed, nothing is echoed to mark the effect, unless some other line-related echo option (e.g. echoke) would cause this
echoprt use a mode of character erasure suitable for a hardcopy device: characters are re-echoed in order of deletion, deleted characters being surrounded by “\” and “/”
−echoprt do not use the hard-copy style erase echoing
echoke for line kill, use the echoe mode of erase for each character, wiping out the line completely from the display rather than just taking a new one
−echoke if a line is killed, do not wipe it out
echoctl control characters which are not special (or are quoted via lnextc) are echoed in the form “^x” where x is a printable ASCII character in the range ‘@’ through ‘_’ for control character codes in the range 0 through 31, or ‘?’ for ASCII DEL (code 127); if the control character is in the upper half of the full 8-bit character range (i.e. 128..159) then the form “|x” is used instead; when the eof character (default EOT, ^D) is echoed in this mode, it will be backspaced over so that subsequent output (other than a newline) will overwrite it.
−echoctl echo control characters back without translation; if the opost and noeot options are both set then EOT (^D) will not be echoed at all
crt set echo options suitable for interactive use on a video terminal (echoe echok echoke echoctl)
hardcopy set echo options suitable for interactive use on a hardcopy device (echoprt echoctl −echoe −echoke)
icanon set the terminal into canonical input mode, where line editing is possible using the erase, kill and werase characters, and where the newline, eol and eof characters terminate an input line and make it available to a process reading from the terminal; the backslash character may be used as a prefix to escape the erase, kill, werase and eof characters, if they are to be input without their special meaning
−icanon set the terminal into non-canonical mode (not normally used from the command line); in this mode, line editing is not available (the erase, kill and werase characters are not treated specially), and input typed becomes available to a reading process immediately − the newline, eof and eol characters cease to have any special effect as line terminators; also in this mode, the min and time special values are used to control the behaviour of the read(2) function when applied to the terminal
icrnl convert received ASCII CR (Carriage Return) characters into newline characters (NL, ASCII LF)
-icrnl leave received CR characters alone (unless igncr is set)
igncr ignore received CR characters completely
−igncr accept received CR characters, treating them according to the setting of icrnl
inlcr convert received NL (ASCII LF) characters into CR characters
−inclr leave received NL characters as they are
iuclc convert received upper case characters (A-Z) to lower case (only applicable if iexten is set)
−iuclc do not convert received upper case characters to lower case
iexten enable extended input input options, i.e. those features which are not specified in the POSIX standard (IEEE 1003.1); this option is normally set, and it must be set for the iuclc and ixany flags, and the werase, dsusp, reprint, flush and lnext special characters to be effective
−iexten disable input processing extensions: only those input options and special characters defined by IEEE 1003.1 will be recognised
Flow control
ixon apply flow control to output: if the stop character (default ^S) is received as input, output will be suspended as soon as possible; if the start character (default ^Q) is then typed, output will be restarted − this allows user control of scrolling when large amounts of text are being displayed, and is also useful when the output device is not a user terminal but a hardware periperal (or another computer) which requires that its rate of data input be moderated
−ixon disable flow control of output; the start and stop characters will not be checked for on reception of input data, i.e. they are not treated as special
ixany if ixon is set, allow any input character (not just the start character) to restart output which was suspended by the stop character (only applicable if iexten is set)
−ixany allow only the start character to restart stopped output
ixoff apply flow control to input − normally only used when the interface is attached to a special peripheral or another computer which can generate high rates of data as input; if the level of input data queued for reading exceeds a certain threshold (normally 127 bytes), a stop character will be transmitted to the other end for each received input character, until the input level drops again; should the input level subsequently exceed a second, higher threshold (normally 255), all unprocessed input data will be silently discarded and a start character transmitted − this should be an exceptional event for a properly configured connection.
mdmbuf use modem control signals to perform output flow control
−mdmbuf
do not use modem signals to perform output flow control
Job control
tostop a background job attempting to write to the terminal will be sent a signal SIGTTOU which will normally stop the job
−tostop a background job is permitted to write to the terminal
Output processing
opost perform output processing controlled by the remaining output options
−opost do not perform any output processing, all other output options are ignored
onlcr convert the newline character (NL) to the two characters CR, NL on output
−onlcr leave the newline character as itself on output
ocrnl convert the CR character to newline (NL) on output
−ocrnl leave CR alone as itself on output
onocr do not send CR characters when the output device is at column 0
-onocr always output a CR character when requested
onlret indicates that the terminal performs the full newline function (including moving to column 0) when it is sent the NL character: this allows the terminal driver to keep track of column position
−onlret indicates that the terminal does not move to column 0 when a NL is sent to it
maptilde when the tilde character (~) is to be output or echoed, transmit the backquote character (`) instead; this option is required for some Hazeltine terminals which do not display the tilde character
−maptilde
output the tilde character with no special treatment
noeot the ASCII character EOT (code 4, ^D) will be filtered from any output or echoed data; this is intended to protect against the unpleasant effects this code can cause on some types of terminal
−noeot do not perform any filtering on the EOT character
xcase when output or echoed, upper case characters are preceded by a backslash (to distinguish them from lower-case characters converted to upper case with olcuc) and the other characters (‘{’, ‘|’, ‘}’ and ‘~’) not printable by some older terminals are displayed as respectively ‘\(’, ‘\!’, ‘\)’ and ‘\^’; this option is normally used only in conjunction with olcuc and iuclc
−xcase upper case letters and the other characters described under xcase will be displayed without special treatment
The following options control the treatment of certain characters when output or echoed to the terminal; for some hardcopy terminals, it is necessary to give them extra time to perform the physical operations associated with certain control characters (BS, CR, FF, NL, TAB, VT). This is achieved either by simplying delaying further output following the transmission of the character, or by sending padding characters (which will be ignored by the terminal) for the specified length of time. For each character, exactly one of the available delay options will be applied, i.e. these are 1-of-n options rather than individual boolean flags; if the chosen option ends in 0 then no delay will be applied for that character. The exact delays generated are controlled by the terminal driver and are not optimal for all devices; all delay times given below are approximate. Note that when stty −g is used, only delay options with a value other than 0 are displayed.
bs0 bs1 delay inserted after BS is output: bs1 gives a delay of 60ms
cr0 cr1 cr2 cr3
delay when CR is output: for cr1, delay is related to column position before the CR is sent − if at column 0, there is no delay, otherwise the delay varies between 70ms and 100ms with increasing column position; cr2 gives a delay of 90ms; cr3 a delay of 130ms
ff0 ff1 delay when FF (Form Feed) is output; ff1 gives a delay of 1.3 seconds
nl0 nl1 delay when NL (newline, ASCII LF, Line Feed) is output; nl1 gives a delay of 90ms, but if onlret is set than the current CR delay will be used instead of the NL delay when NL is output
tab0 tab1 tab2 tab3 tabs −tabs tab8
treatment of tabs: tab0 or tabs means that TAB is simply passed to the terminal with no delay; tab1 gives a delay related to how much motion the TAB will cause (assuming that TAB moves to the next 8-column multiple): if the distance is less than five columns then no delay is used, otherwise the delay varies from 90ms through 120ms; tab2 gives a constant delay of 60ms; tab3 is special in that it does not generate a delay but rather causes the normal effect of TAB on output to be simulated by converting it to a sequence of from 1 to 8 spaces according to the current column position; −tabs and tab8 are equivalent to tab3
vt0 vt1 delay when the VT character (Vertical Tab) is output; vt1 gives a delay of 1.3 seconds
ofill causes delays to be implemented by transmitting padding characters during the delay period
−ofill causes delays to be implemented by simply transmitting no data during the delay period
ofdel if ofill is set then ASCII DEL (code 127 decimal) will be used as the padding character
−ofdel if ofill is set then ASCII NUL (code 0) will be used as the padding character
Combination modes
nl set options suitable for a terminal which generates NL (LF) as its normal newline character and handles NL (LF) by performing the normal newline display function; this is equivalent to (−icrnl −onlcr).
−nl set options suitable for a terminal which generates CR as its normal newline character and requires to receive CR along with NL (LF) to perform the newline display function; equivalent to (icrnl onlcr −inlcr -igncr -ocrnl -onlret)
raw set terminal into “raw” mode: the data format is set to 8 bits wide with no parity, no signals are generated by input characters, non-canonical input mode is established and no output post-processing is done
lcase
LCASE set all options suitable for a terminal which does not generate or display lower case characters; equivalent to (iuclc xcase olcuc)
-lcase
-LCASE set options for a terminal which can generate and display both upper and lower case characters; equivalent to (−iuclc −xcase −olcuc)
-raw
cooked set normal input and output options, reversing the effect of raw
ek set the erase and kill characters to their defaults (^? and ^U respectively)
sane set terminal options to a generally “sensible” state
Special characters
The special characters for the terminal can be changed by supplying an option comprised of two command arguments: “specname code” where specname is one of the names listed below, and code is either just the code itself given literally as a single-character argument, or has the form “^x” where x is in the range ‘@’ through ‘_’ for control codes in the range 0 through 31, or ‘?’ for control code 127 (ASCII DEL), or ‘-’ to mean that the special character action should be disabled, i.e. no received character will be recognised as performing the special function. Default values are shown in parentheses. The start and stop characters are displayed using this format for the command stty -g, but are (currently) not modifiable using stty.
intr character used to cause generation of SIGINT, the normal program interrupt signal (^C)
quit character used to cause generation of SIGQUIT (^)
erase character used to rubout the previous character on the input line, if any (DEL, ^?)
kill character used to cause the whole of the input line entered so far to be discarded (^U)
eof character used to simulate End-Of-File to a process reading from a terminal (^D)
eol alternative end-of-line character (undefined)
The following special characters are functional only when the new or posix line disciplines are being used, and are not normally changed. The normal default values are shown in parentheses for each character; however if the terminal is locked into posix mode, the default setting (established when the terminal is opened) for all of the following characters except the susp character is that it is undefined, i.e. the special function is disabled. In the latter situation, stty may of course still be used to set these characters to a particular desired value. For all of the following options apart from susp, the special function is disabled if the iexten flag is not set, as these are extensions to the IEEE 1003.1 set of special characters.
discard
flush character used to toggle the temporary discarding of output; flushing is terminated automatically by echo of a character or by a process performing a read from the terminal (^O)
reprint
rprint character used to cause all input not yet read by a process to be re-echoed to the terminal; typically used when echoing of the current input line has been confused by output written to the terminal (^R)
susp character used to suspend execution of the foreground job, when job control (^Z) is in use
dsusp character used to suspend execution of the foreground job at the point where the special character would be read as input (^Y)
werase character used to cause the previous ‘word’ on the current input line; a word is any group of characters delimited by spaces or tabs (^W)
lnext character used to prevent any special interpretation of the character it precedes; used to input otherwise special characters as ordinary data (^V)
Special values
Two special values for the terminal can be changed by supplying an option comprised of two command arguments: “specname value” where specname is one of min or time, and value is a number in the range 0 through 255. The two special values define the behaviour of the read(2) system call when the terminal is in non-canonical mode (-icanon). Note that it is uncommon to actually set these values using stty, rather they are typically set up by programs which need to handle character input in a special way (e.g. screen editors). Refer to the POSIX (IEEE 1003.1) standard or the X/Open Portability Guide for a fuller explanation of the treatment of these two values,
Internal state
The following options are not normally modified by, or of interest to, ordinary users; they relate to internal state of the terminal driver, and are typically of use only in system diagnosis.
flusho data written to the terminal is being flushed (discarded); this occurs when the terminal user has typed the flush character
−flusho data sent to the terminal (or echoed) will appear as output; this is the normal state
pendin when the state of the terminal is switched between canonical and non-canonical input, any already queued data is marked to be re-input on the next read(2) operation or when further input arrives; this state only holds while re-input is pending
−pendin no re-input of characters is pending
LIMITATIONS
There is no separate control over input and output speeds, even though commonly the hardware would allow them to be different.
The start and stop character values are displayed by the -a flag, but there is no option to change them, even though the underlying driver supports this.
There is no means to access the window size information maintained by the system for each attached terminal (the BSD stty(1) command gives access to this information).
SEE ALSO
stty (1v), ioctl(2), tabs(1), tset(1), tty(4)
X/Open Portability Guide Issue 3, volumes 1 and 2.
4th Berkeley Distribution — Revision 1.2 of 10/12/90