stty
Set or print terminal I/O characteristics
TLDR
Display current terminal size
Display all settings for the current terminal
Set the number of rows or columns
Get the actual transfer speed of a device
Reset all modes to reasonable values for the current terminal
Switch between raw and normal mode
Turn character echoing off or on
Display help
SYNOPSIS
stty [-a|-g] [-F DEVICE] [SETTING ...]
PARAMETERS
-a
Print all current settings in human-readable form.
-g
Print all current settings in stty-readable form (can be used as input to another stty command).
-F DEVICE
Open and use the specified DEVICE instead of standard input.
SETTING
Modify a specific terminal setting. Numerous settings exist, including baud rate, control characters (e.g., intr
for interrupt character), echoing options, and flow control settings. Refer to the stty
man page for a comprehensive list.
raw
Set raw mode. Input is passed directly without interpretation.
cooked
Set cooked mode. Enable line editing and other standard terminal features.
echo
Enable echoing of input characters.
-echo
Disable echoing of input characters.
ispeed BAUD
Set the input baud rate to BAUD.
ospeed BAUD
Set the output baud rate to BAUD.
DESCRIPTION
The stty
command is a fundamental utility for controlling the behavior of a terminal interface in Unix-like operating systems. It allows users to configure a wide array of settings related to input, output, and control characters. stty
can be used to both display the current terminal settings and to modify them. Its versatility is invaluable for customizing the terminal environment to suit specific needs or to resolve issues related to terminal behavior. Common uses include setting the baud rate, configuring character echoing, and adjusting flow control mechanisms. The command's numerous options provide granular control over nearly every aspect of the terminal, enabling fine-tuning for optimal interaction with command-line applications and other programs. It is critical for programs that relies on consistent terminal behavior.
CAVEATS
Changes made with stty
are typically only effective for the current terminal session. To make permanent changes, the command must be included in a shell startup script (e.g., .bashrc
or .zshrc
). Some settings may be overridden by applications that directly manipulate the terminal.
CONTROL CHARACTERS
stty
can be used to set control characters like interrupt (intr
), end-of-file (eof
), and quit (quit
). For example, stty intr ^C
sets the interrupt character to Ctrl+C.
FLOW CONTROL
stty
can manage flow control mechanisms like XON/XOFF (software flow control) and hardware flow control (using RTS/CTS signals). Options like ixon
and ixoff
enable and disable XON/XOFF, respectively. crtscts
enables hardware flow control.
HISTORY
stty
has been a core part of Unix since its early days. Its fundamental role in configuring terminal behavior has ensured its continued presence in virtually all Unix-like operating systems. Over time, the specific options and features of stty
have evolved to accommodate new terminal technologies and user needs, but its basic function remains the same: to provide a flexible and powerful means of controlling the terminal environment.