Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

stty - check and change terminal options (set terminal type)

&pagelevel(4)&pagelevel

stty can be used to check or change terminal options.

Depending on the implementation, some stty options such as parext, iexten and stflush are accepted but not interpreted by the driver, so these options will not have any effect.

The stty command is only useful when you are accessing the POSIX shell via rlogin. The stty command has no effect on BS2000 block-mode terminals; stty can only be used to change the options on character-mode terminals.


Syntax


No option specified

stty reports some of the option settings for the device that is its current standard input.

Options for defining the scope of the output

-a

(a - all)

Reports all currently valid terminal option settings.

-g

Reports current settings in a form that can be used as input to another stty command.

Options for setting input/output characteristics

The following section describes the various options available when setting I/O characteristics for the terminal that is stty’s current standard input. The I/O options are listed in five main groups:

  • Data transfer control options

  • Input control options

  • Output control options

  • Local features

  • Control assignments.

An additional group constitutes combinations of options from these five groups.

Explanations related to parenthesized options are also indicated within parentheses.

Note that even though many combinations of options make no sense, stty does no sanity checking.

Data transfer control options

As serial lines are not supported on BS2000, the data transfer control options do not work. They are summarized here for reasons of completeness:

parenb

Enable parity generation and detection

parext

Extended parity generation and detection

parodd

Odd parity

csize

Define character size: cs5, cs6, cs7 or cs8

ispeed number

Set terminal input baud rate to number

ospeed number

Set terminal output baud rate to number

number

Set baud rate to number

hupcl

Hang up connection on last close()

hup

Same as hupcl

cstopb

Use two stop bits per character

cread

Enable receiver

clocal

Modem control signals not supported

Input control options

The following options can be used to control the input of data:

ignbrk (-ignbrk)

Ignore (do not ignore) break on input.

brkint (-brkint)

Send (do not send) SIGINT on break.

ignpar (-ignpar)

Ignore (do not ignore) parity errors.

parmrk (-parmrk)

Mark (do not mark) characters with parity errors.

inpck (-inpck)

Enable (disable) parity checking on input.

istrip (-istrip)

Mask (do not mask) input characters to 7 bits.

inlcr (-inlcr)

Map (do not map) newline character to carriage return on input.

igncr (-igncr)

Ignore (do not ignore) carriage returns on input.

icrnl (-icrnl)

Map (do not map) carriage return to newline character on input.

iuclc (-iuclc)

Map (do not map) uppercase letters to lowercase on input.

ixon (-ixon)

Enable (disable) START/STOP output control. Output is stopped by sending an ASCII DC3 and started by sending an ASCII DC1.

ixany (-ixany)

Allow any character (only the ASCII character DC1) to restart output.

ixoff (-ixoff)

Request that the system send (not send) START/STOP characters when the input queue is nearly empty/full.

Output control options

The following options can be used to control the output of data:

opost (-opost)

Post-process output in accordance with the other specified options (do not post-process output: ignore all other output control options).

olcuc (-olcuc)

Map (do not map) lowercase letters to uppercase on output.

ocrnl (-ocrnl)

Map (do not map) carriage return to newline character on output.

onocr (-onocr)

Do not (do) output carriage return in column 0.

onlret (-onlret)

A newline character also performs (does not perform) the carriage return function on output.

ofill (-ofill)

Use fill characters (use timing) for data transmission delays.

ofdel (-ofdel)

Use abort character DEL 0x7f (null character NUL 0x0) as fill character.

cr0 cr1 cr2 cr3

Select extent of delay for carriage returns on output.

nl0 nl1

Select extent of delay for newline characters on output.

tab0 tab1 tab2 tab3

Select extent of delay for horizontal tabs on output.

bs0 bs1

Select extent of delay for backspaces on outpu).

ff0 ff1

Select extent of delay for form feeds on output.

vt0 vt1

Select extent of delay for vertical tabs on output.

Local features

isig (-isig)

Enable (disable) the checking of each input character against the special control characters intr, quit, and swtch (see “Control assignments”). If a match is found, the function associated with the control character is executed (not executed).

icanon (-icanon)

Enable (disable) canonical input, i.e. the special functions of the characters erase and kill are (are not) performed on input.

xcase (-xcase)

Enable (disable) canonical uppercase/lowercase presentation.

echo (-echo)

Echo back (do not echo back) every character typed.

echoe (-echoe)

Echo (do not echo) erase characters as a backspace-space-backspace string.


Setting the echoe option will erase the character overwritten with erase on many terminals; however, since this mode does not keep track of the column position, problems may arise with escaped characters, tabs, and backspaces.


echok (-echok)

Output (do not output) an additional newline after a kill character.

echonl (-echonl)

Output (do not output) newline characters.

noflsh (-noflsh)

Disable (enable) the flushing of input and output queues on detection of an intr, quit, or swtch signal.

tostop (-tostop)

Send (do not send) SIGTTOU when background processes write to the terminal.

iexten (-iexten)

Enable (disable) special control characters not currently controlled by icanon, isig, ixon or ixoff.

Control assignments

control-character c

Set control-character to c, where control-character can be: ctab, discard, dsusp, eof, eol, eol2, erase, intr, kill, lnext, quit, reprint, start, stop, susp, swtch, werase, min or time (min and time are used with -icanon; ctab is used with -stappl).

If c is preceded by the ^ character, then the value used is the corresponding CTRL character (e.g. ^D corresponds to CTRL+D). ^? is interpreted as CTRL-C, and ^- is interpreted as undefined.

min number/time number

Set the value of min or time to number. min and time are used with -icanon
(see termio() [4]).

line i

Set line discipline to i (0 < i < 127).

Combination modes

The following combination modes may be used to control the terminal:

evenp or parity

Enable parenb and cs7.

oddp

Enable parenb, cs7, and parodd.

-parity or -evenp

Disable parenb, and enable cs8.

-oddp

Disable parenb and parodd, and enable cs8.

raw (-raw or cooked)

Enable (disable) raw input and output; raw mode is equivalent to: cs8, with no erase, kill, intr, quit, swtch, eof, or output post-processing, and no parity bit.

nl (-nl)

Disable (enable) icrnl, and onlcr. In addition, -nl disables inlcr, igncr, ocrnl, and onlret.

lcase (-lcase)

Enable (disable) xcase, iuclc, and olcuc.

LCASE (-LCASE)

Same as lcase (-lcase).

tabs (-tabs or tab8)

Preserve tabs (expand to spaces) when printing.

ek

Reset control characters erase and kill back to system-specific default values.

sane

Reset all terminal options to some reasonable values.

Locale

The following environment variables affect the execution of stty:

LANG

Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined.

LC_ALL

If set to a non-empty string value, override the values of all the other internationalization variables.

LC_CTYPE

Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other.

LC_MESSAGES

Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.

NLSPATH

Determine the location of message catalogs for the processing of LC_MESSAGES.

Example 1

Check current settings (only on access to POSIX shell via rlogin):

$ stty -a
speed 38400 baud;
intr = DEL; quit = ^\; erase = ^h; kill = ^x;
eof = ^d; eol = <undef>; eol2 = <undef>; swtch = <undef>;
start = ^q; stop = ^s; susp = ^z; dsusp = <undef>;
rprnt = ^r; flush = ^o; werase = ^w; lnext = ^v;
-parenb -parodd cs8 -cstopb hupcl cread -clocal -loblk -parext
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iuclc
ixon -ixany -ixoff -imaxbel
isig icanon -xcase echo echoe echok -echonl -noflsh
-tostop -echoctl -echoprt -echoke -defecho -flusho -pendin -iexten
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel -tabs

Example 2

If you have inadvertently performed an action that causes inputs not to be shown on the screen, you can restore the screen display by entering the following command:

$ stty echo

The input of the above command will, however, not be displayed.

Example 3

Reset all terminal settings to reasonable values:

$ stty sane

Example 4

The terminal settings can also be reset with the aid of the -g option:

$ STATUS=`stty -g `

The above command defines a variable with the current settings of the terminal (which may differ from those of stty sane). The existing terminal settings can now be changed by resetting them with:

$ stty $STATUS

See also

ioctl() [4]