The stty command sets certain I/O options for the device that is the current standard input. This command writes output to the device that is the current standard output.
This version of the operating system uses the standard interface to control the terminals, maintaining a compatibility with POSIX and BSD interfaces. The stty command supports both POSIX and BSD compliant options, but the usage of POSIX options is strongly recommended. A list of obsolete BSD options, with the corresponding POSIX options, is also provided.
When you redirect standard input from a tty device by typing:
the stty command (POSIX) will hang while waiting for the open() of that tty until the RS-232 carrier detect signal has been asserted. Exceptions to this rule occur if the clocal or forcedcd (128-port only) option is set.
These options are extensions to the X/Open Portability Guide Issue 4 standard.
| Extension | Description |
|---|---|
| cdxon | Enables CD hardware flow control mode on output. |
| -cdxon | Disables CD hardware flow control mode on output. |
| ctsxon | Enables CTS hardware flow control mode on output. |
| -ctsxon | Disables CTS hardware flow control mode on output. |
| dtrxoff | Enables DTR hardware flow control mode on input. |
| -dtrxoff | Disables DTR hardware flow control mode on input. |
| rtsxoff | Enables RTS hardware flow control mode on input. |
| -rtsxoff | Disables RTS hardware flow control mode on input. |
To assign a control character to a character string, type:
stty Control String
The String parameter may be any single character such as c. An example of this control assignment is:
stty STOP c
Another way of assigning control characters is to enter a character sequence composed of a \^ (backslash, caret) followed by a single character. If the single character after the ^ (caret) is one of the characters listed in the ^c (caret c) column of the following table, the corresponding control character value will be set. For example, to assign the DEL control character by using the ? (question mark) character, type the string \^? (backslash, caret, question mark), as in:
stty ERASE \^?
| ^c | Value |
|---|---|
| a, A | <SOH> |
| b, B | <STX> |
| c, C | <ETX> |
| d, D | <EOT> |
| e, E | <ENQ> |
| f, F | <ACK> |
| g, G | <BEL> |
| h, H | <BS> |
| i, I | <HT> |
| j, J | <LF> |
| k, K | <VT> |
| l, L | <FF> |
| m, M | <CR> |
| n, N | <SO> |
| o, O | <SI> |
| p, P | <DLE> |
| q, Q | <DC1> |
| r, R | <DC2> |
| s, S | <DC3> |
| t, T | <DC4> |
| u, U | <NAK> |
| v, V | <SYN> |
| w, W | <ETB> |
| x, X | <CAN> |
| y, Y | <EM> |
| z, Z | <SUB> |
| [ | <ESC> |
| \ | <FS> |
| ] | <GS> |
| ^ | <RS> |
| _ | <US> |
| ? | <DEL> |
| @ | <NUL> |
| Combination mode | Description |
|---|---|
| cooked | See the -raw option. |
| ek | Sets ERASE and KILL characters to the Ctrl-H and Ctrl-U key sequences, respectively. |
| evenp | Enables parenb and cs7. |
| -evenp | Disables parenb and sets cs8. |
| lcase, LCASE | Sets xcase, iuclc, and olcuc. Used for workstations with uppercase characters only. |
| -lcase, -LCASE | Sets -xcase, -iuclc, and -olcuc. |
| nl | Sets -icrnl and -onlcr. |
| -nl | Sets icrnl, onlcr, -inlcr, -igncr, -ocrnl, and -onlret. |
| oddp | Enables parenb, cs7, and parodd. |
| -oddp | Disables parenb and sets cs8. |
| parity | See the evenp option. |
| -parity | See the -evenp option. |
| sane | Resets parameters to reasonable values. |
| raw | Allows raw mode input (no input processing, such as erase, kill, or interrupt); parity bit passed back. |
| -raw | Allows canonical input mode. |
| tabs | Preserves tabs. |
| -tabs, tab3 | Replaces tabs with spaces when printing. |
| Window size | Description |
|---|---|
| cols n, columns n | The terminal (window) size is recorded as having n columns. |
| rows n | The terminal (window) size is recorded as having n rows. |
| size | Prints the terminal (window) sizes to standard output (first rows and then columns). |
stty ixon ixanyThis sets ixon mode, which lets you stop runaway listing by pressing the Ctrl-S key sequence. The ixany flag allows you to resume the listing by pressing any key. The normal workstation configuration includes the ixon and ixany flags, which allows you to stop a listing with the Ctrl-S key sequence that only the Ctrl-Q key sequence will restart.
Sometimes the information displayed on the screen may look strange, or the system will not respond when you press the Enter key. This can happen when you use the stty command with parameters that are incompatible or that do things you don't understand. It can also happen when a screen-oriented application ends abnormally and does not have a chance to reset the workstation configuration.
Entering the stty sane command sets a reasonable configuration, but it may differ slightly from your normal configuration.
OLDCONFIG=`stty -g` # save configuration stty -echo # do not display password echo "Enter password: \c" read PASSWD # get the password stty $OLDCONFIG # restore configurationThis command saves the workstation's configuration, turns off echoing, reads a password, and restores the original configuration.
Entering the stty -echo command turns off echoing, which means that the password does not appear on the screen when you type it at the keyboard. This action has nothing to do with the echo command, which displays a message on the screen.
| /usr/bin/stty | Contains the stty command. |