5 Unix / Linux STTY Command Examples for Terminal Settings

stty command is used to manipulate the terminal settings. You can view and modify the terminal settings using this command as explained below.

1. Display All Settings

-a option displays all the stty settings in a user friendly readable format as shown below.

# stty -a
speed 38400 baud; rows 59; columns 208; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ; eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts -cdtrdsr
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

You can also speciay -all, which is same as -a.

stty --all

2. Display All Settings (in Stty format)

The following will display all the settings in a format that is readable by stty. Please note that this is not in readble format. You’ll typically use this if you want to transfers the settings between systems.

# stty -g
500:5:bf:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0

You can also use –save option, which is same as -g

# stty --save
500:5:bf:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0

3. Specify Device

You can specify a device file as an argument to stty command. In that case, it will use the device that you’ve specified instead of using the standard input.

# stty -F /dev/pts/0
speed 38400 baud; line = 0;
-brkint -imaxbel

4. Set a Stty Value

The following example sets a stty value istrip.

# stty istrip

As you see below, istrip is set

# stty -a | grep istrip
-ignbrk -brkint -ignpar -parmrk -inpck istrip -inlcr -igncr icrnl ixon -ixoff

5. Negate a Stty Value

To negate a stty value, you need to specify a – in front of the value. The following example negates the stty value istrip.

# stty -istrip

As you see below, istrip is negated. i.e there is a – in front of the istrip.

# stty -a | grep istrip
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff

Comments on this entry are closed.