Sets, resets, and reports workstation operating parameters.
stty [ -a ] [ -g ] [ Options ]
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:
stty -a </dev/ttyx
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.
| -a | Writes the current state of all option settings to standard output. |
| -g | Writes option settings to standard output in a form usable by another stty command. |
The stty command supports following categories of options:
| Control mode | Description |
|---|---|
| clocal | Assumes a line without modem control. |
| -clocal | Assumes a line with modem control. |
| cread | Enables the receiver. |
| -cread | Disables the receiver. |
| cstopb | Selects 2 stop bits per character. |
| -cstopb | Selects 1 stop bit per character. |
| cs5, cs6, cs7, cs8 | Selects character size. |
| hup, hupcl | Hangs up dial-up connection on the last close. |
| -hup, -hupcl | Does not hang up dial-up connection on the last close. |
| parenb | Enables parity generation and detection. |
| -parenb | Disables parity generation and detection. |
| parodd | Selects odd parity. |
| -parodd | Selects even parity. |
| 0 | Hangs up phone line immediately. |
| speed | Sets the workstation input and output speeds to the specified speed number of bits per second. All speeds are not supported
by all hardware interfaces. Possible values for speed are: 50, 75, 110, 134, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 19.2, 38400, 38.4, exta, and extb.
Note:
exta, 19200, and 19.2 are synonyms; extb, 38400, and 38.4 are synonyms. |
| ispeed speed | Sets the workstation input speed to the specified speed number of bits per second. All speeds are not supported by all hardware interfaces, and all hardware interfaces do not support this option. Possible values for speed are the same as for the speed option. |
| ospeed speed | Sets the workstation output speed to the specified speed number of bits per second. All speeds are not supported by all hardware interfaces, and all hardware interfaces do not support this option. Possible values for speed are the same as for the speed option. |
These options are extensions to the X/Open Portability Guide Issue 4 standard.
To assign a control character to a character string, type:
stty Control String
where the Control parameter may be the INTR, QUIT, ERASE, KILL, EOF, EOL, EOL2, START, STOP, SUSP, DSUSP, REPRINT, DISCARD, WERASE, LNEXT, MIN, or TIME character. (Use the MIN and TIME characters with the -icanon option.)
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. |
The following BSD options are supported by the stty command. For each of them, the recommended POSIX option is given.
| Option | Description |
|---|---|
| all | Use the stty -a command to display all current settings. |
| crt | Use the sane option to reset parameters to reasonable values. |
| crtbs | Use the -echoe option. |
| crterase | Use the echoe option. |
| -crterase | Use the -echoe option. |
| crtkill | Use the echoke option. |
| -crtkill | Use the echok and -echoke options. |
| ctlecho | Use the echoctl option. |
| -ctlecho | Use the -echoctl option. |
| decctlq | Use the -ixany option. |
| -decctlq | Use the ixany option. |
| even | Use the evenp option. |
| -even | Use the -evenp option. |
| everything | Use the stty -a command to display all current settings. |
| litout | Use the -opost option. |
| -litout | Use the opost option. |
| odd | Use the oddp option. |
| -odd | Use the -oddp option. |
| pass8 | Use the -istrip option. |
| -pass8 | Use the istrip option. |
| prterase | Use the echoprt option. |
| speed | Use the stty command to display current settings. |
| tandem | Use the ixoff option. |
| -tandem | Use the -ixoff option. |
stty
This lists settings that differ from the defaults.
stty ixon ixany
This 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 configuration
This 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. |