[Previous] [Contents] [Next]

stty

Set tty attributes (POSIX)

Syntax:

stty [-a|-g] [operands] [< device]

Options:

-a
Display all settings.
-g
Display in "getable" form.

Description:

The stty utility sets and/or reports terminal I/O characteristics for the device that is its standard input. If no operands are specified, stty displays the settings. If operands are given, then stty will change the terminal state to reflect those settings.

Terminal settings fall into two major categories: edit mode or raw mode. In edit mode, input data can be edited by the user, and is made available to programs only when an Enter is pressed. Output data will normally be presented in a human-readable format. In raw mode, all data flows to and from the terminal with little extra processing. If you're at a shell prompt, your terminal will probably be in the default system edit mode. A fullscreen program such as an editor, on the other hand, typically puts the terminal into raw mode.

Normally, stty displays only significant settings relative to the system default settings for edit or raw, and will display only the defined control characters. If -a or -g are specified, then stty will display all the settings.

The stty utility manages a very large number of potential terminal attributes and control characters. Most of these parameters are very device-specific and will seldom need to be changed by the user. Programs often change these terminal attributes in the course of their operation, and upon occasion (such as abnormal termination) may leave the terminal settings in an unknown state. The stty +edit option is a convenient method of restoring a terminal to a usable state.

Supported operands

The complete list of operands supported by stty are provided in the following tables. In these tables, the following conventions are used:

number
represents a decimal integer number (e.g. 9600).
name
represents a string of characters (e.g. vt100).
value
can be a single character (e.g. ~) or a 2-digit hexadecimal number (e.g. 1B) or one of the following character pairs:
Char pair  Hex
^- 00 (undefined)
^A to ^Z 01 to 1A
^[ 1B
^\ 1C
^] 1D
^^ 1E
^_ 1F
^? 7F

An option that starts with {+|-} can start with either of these characters:

+
(turn the option on)
-
(turn the option off)

If neither + nor - is specified, + is assumed.

Also note that the = character is optional in operands of the form keyword=value.


Note: The following descriptions give the action taken when the option is on.

Line control parameters

Parameter Defines
baud=number define input and output baud rates
ispeed=number define input baud rate
ospeed=number define output baud rate
par=none no parity (same as -parenb)
par=odd odd parity (same as +parenb, +parodd, -parstk)
par=even even parity (same as +parenb, -parodd, -parstk)
par=mark mark parity (same as +parenb,+parodd, +parstk)
par=space space parity (same as +parenb, -parodd, +parstk)
bits=5 5-bit characters
bits=6 6-bit characters
bits=7 7-bit characters
bits=8 8-bit characters
stopb=2 2-stop bits
stopb=1 1-stop bits
{+|-}parenb enable parity
+parodd odd parity
-parodd even parity
{+|-}parstk stick parity
+cs5 same as bits=5
+cs6 same as bits=6
+cs7 same as bits=7
+cs8 same as bits=8
+cstopb same as stopb=2
-cstopb same as stopb=1
number same as baud=number
+evenp same as par=even, bits=7
-evenp same as par=none, bits=8
+parity same as par=even, bits=7
-parity same as par=none, bits=8
+oddp same as par=odd, bits=7
-oddp same as par=none, bits=8
{+|-}hupcl hangup on last close
{+|-}hup same as hupcl
{+|-}cread enable receiver
{+|-}clocal assume no modem control
{+|-}ihflow enable hardware input flow control
{+|-}ohflow enable hardware output flow control
{+|-}isflow enable software input flow control
{+|-}osflow enable software output flow control
{+|-}lkhflow lock hardware flow control (ihflow/ohflow)
{+|-}lksflow lock software flow control (isflow/osflow)
{+|-}ihpaged input is paged by hardware flow control
{+|-}ohpaged output is paged by hardware flow control
{+|-}ispaged input is paged by software flow control
{+|-}ospaged output is paged by software flow control

Input processing parameters

Parameter Defines
{+|-}ignbrk ignore received hardware breaks
{+|-}brkint generate SIGINT upon break
{+|-}ignpar ignore parity errors
{+|-}parmrk mark parity errors
{+|-}inpck enable software parity checking
{+|-}istrip strip 8th bit from received characters
{+|-}inlcr map newline into carriage-return on input
{+|-}igncr ignore received carriage-return
{+|-}icrnl map carriage-return into newline on input
{+|-}ixon same as osflow
{+|-}ixoff same as isflow
{+|-}isig generate signals upon receipt of special characters
{+|-}icanon enable input line editing
{+|-}iexten enable "extra" special characters
{+|-}echo echo received characters
{+|-}echoe erase character will erase displayed character
{+|-}echok kill character will erase displayed line
{+|-}echonl echo newline, even if ECHO is off
{+|-}noflsh don't flush I/O after INTR, QUIT, or SUSP
+flush flush input and output data immediately
min=number minimum characters required to satisfy raw input
time=number timeout value for raw input
+nl same as +icrnl
-nl same as -icrnl, -inlcr, -igncr
+sane reset all parameters to sane values based on current mode (edit/raw)
+fix same as +sane
+edit reset parameters to system default edit mode
+raw reset parameters to system default raw mode

Output processing parameters

Parameter Defines
{+|-}opost post-process output data

Special control characters

Parameter Defines
eof=value end-of-file character
eol=value end-of-line character
erase=value delete previous character
kill=value delete entire line character
intr=value generate SIGINT character
quit=value generate SIGQUIT character
susp=value generate SIGTSTP character
stop=value stop output
start=value resume output
+ek resets ERASE and KILL to system defaults

Extended line-editing character sequences

QNX supports multi-character sequences to support editing capabilities in addition to the basic "erase" and "kill" functions. All of these sequences are assumed to start with an (up to) 4-character prefix, a single-character action, followed by an (up to) 4-character suffix. Typically, the cursor keys on your terminal will be used for these functions.

Parameter Meaning
+load set editing keys based on currently defined terminal type
term=name set editing keys for the specified type of terminal
pr1=value first character of prefix
pr2=value second character of prefix
pr3=value third character of prefix
pr4=value fourth character of prefix
sf1=value first character of suffix
sf2=value second character of suffix
sf3=value third character of suffix
sf4=value fourth character of suffix

Action characters

The following are action characters when preceded by prefix (subsequent suffix will be discarded).

Parameter Meaning
up=value recall previous line
down=value recall next line
left=value move cursor left
right=value move cursor right
ins=value toggle insert mode
del=value delete current character
rub=value delete previous character
can=value delete entire line character
home=value move cursor to beginning of line
end=value move cursor to end of line

Console-specific options

Parameter Meaning
{+|-}numlock keyboard is in Num Lock mode
{+|-}capslock keyboard is in Caps Lock mode
{+|-}scrlock keyboard is in Scroll Lock mode
{+|-}noboot disable keyboard reboot
{+|-}noswitch disable keyboard console switching
{+|-}nodebug disable keyboard debugger entry
{+|-}noresize disable keyboard resizing
{+|-}nohotkey disable keyboard hotkeys
{+|-}nocolor disable colors on console display
{+|-}monocurs force cursor to monochrome adapter values
{+|-}extmode put keyboard into extended mode
{+|-}scanmode put keyboard into scancode mode
rows=rows[,cols] set console size
font=value set console font

Serial port-specific options

Parameter Meaning
{+|-}DTR turn on data-terminal-ready hardware handshaking line
{+|-}RTS turn on request-to-send hardware handshaking line
{+|-}BRK force transmit data line to break condition

Note: The QNX Installation & Configuration manual gives more detailed information concerning the circumstances under which many of these options will be required.

The stty utility usually displays as much information about a device as it can. Unless the -g option is set, the following settings may also be displayed, depending on the type of device:

Serial port information

Parameter Meaning
{+|-}cts clear-to-send line is on
{+|-}dsr data-set-ready line is on
{+|-}ri ring indicator is on
{+|-}cd carrier detect is on

Parallel port information

Parameter Meaning
{+|-}ERR error condition is set
{+|-}ONL printer is online
{+|-}PE paper-empty indicator
{+|-}BSY printer is busy

Examples:

Display settings of the terminal to which stty is attached:

    stty

Display settings of a specified device:

    stty < /dev/ser1

Change the baud rate of a specified device:

    stty baud=1200 < /dev/ser1

Put terminal into a fixed, sane state:

    stty +sane

Set editing keys to VT100 values:

    stty term=vt100

Get current settings into a shell variable:

    saveterm = "$(stty -g)"

Restore settings from a shell variable:

    stty $saveterm

Exit status:

0
The utility executed successfully.
>0
An error occurred.

See also:

cfont

Installation & Configuration


[Previous] [Contents] [Next]