CHAPTER 3 Getting Started
For new users, the most important use of the stty command is setting the erase function to the appropriate key on their terminal. For systems programmers or shell script writers, the stty command provides an invaluable tool for configuring many aspects of I/O control for a given device, including the following:
- erase and line-kill characters
- data transmission speed
- parity checking on data transmission
- hardware flow control
- newline (NL) versus carriage return plus linefeed (CR-LF)
- interpreting tab characters
- edited versus raw input
- mapping of upper case to lower case
This command is very system specific, so consult the man pages for the details of the stty command on your system.
Syntax
stty [options]
Options
(none) report the terminal settings
all (or -a) report on all options
echoe echo ERASE as BS-space-BS
dec set modes suitable for Digital Equipment Corporation operating systems (which distinguishes between ERASE and BACKSPACE) (Not available on all systems)
kill set the LINE-KILL character
erase set the ERASE character
intr set the INTERRUPT character
Examples
You can display and change your terminal control settings with the stty command. To display all (-a) of the current line settings:
% stty -a
speed 38400 baud, 24 rows, 80 columns
parenb -parodd cs7 -cstopb -hupcl cread -clocal -crtscts
-ignbrk brkint ignpar -parmrk -inpck istrip -inlcr -igncr icrnl -iuclc
ixon -ixany -ixoff imaxbel
isig iexten icanon -xcase echo echoe echok -echonl -noflsh -tostop
echoctl -echoprt echoke
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel
erase kill werase rprnt flush lnext susp intr quit stop eof
^H ^U ^W ^R ^O ^V ^Z/^Y ^C ^\ ^S/^Q ^D
You can change settings using stty, e.g., to change the erase character from ^? (the delete key) to ^H:
% stty erase ^H
This will set the terminal options for the current session only. To have this done for you automatically each time you login, it can be inserted into the .login or .profile file that we'll look at later.