Description of Use
The Stty command is used to display and modify terminal row settings (change and print terminal line settings).
Common Parameters
The Stty command prints the terminal line settings without parameters, plus the-a parameter can be printed in more detail.
Stty size can display the terminal's sizes, number of rows and number of columns.
The Stty command can also change the settings of the terminal line, in the following format:
Stty SETTING CHAR
Where the setting can be as follows
EOF: End of input, end of file, default is Ctrl+d. For example: When creating a file with Cat >file, press Ctrl+d to end the input.
Erase: Remove characters backwards, erase the last input character, Ctrl +?. Note By default, the backspace backspace is not a delete character.
Intr: Interrupts the current program, the default is CTRL + C.
Kill: Deletes the entire command, deletes the entire line, and defaults to Ctrl+u.
Quit: Exits the current program, which defaults to ctrl+\ or ctrl+|.
Start: Start screen output, default is Ctrl+q.
Stop: Stops the screen output, which defaults to Ctrl+s.
Susp:terminal Stop Current program, the default is CTRL + Z. This will turn the current process into a background process.
Werase: Deletes the last word, which defaults to ctrl+w.
The Stty command also has some other uses, such as:
Stty-echo turns off Echo. For example, when entering a password in a script.
Stty echo turns on echoing.
Using the sample example one print terminal line Setup
[Email protected] ~]# Stty
Speed 38400 baud; line = 0;
-brkint-imaxbel
[Email protected] ~]# stty-a
Speed 38400 baud; Rows 41; Columns 132; line = 0;
Intr = ^c; Quit = ^\; erase = ^?; Kill = ^u; EOF = ^d; EOL = <undef>; Eol2 = <undef>; Swtch = <undef>; 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
[Email protected] ~]#
Example two prints the size of the current terminal (number of rows and columns)
[Email protected] ~]# stty size
41 132
Example three setting the BACKSPACE backspace delete behavior
By default, when we press the BACKSPACE bar to backspace, we display the ^h on the screen instead of deleting the previous character. such as the use of commands such as Sftp/ftp/sqlplus/ij, you will encounter this situation. We can use the Stty command to change the behavior of BACKSPACE to delete the previous character.
[Email protected] ~]# sftp 192.168.6.12
Connecting to 192.168.6.12 ...
[email protected] ' s password:
Sftp> Get Abc^h^h^h^h
Couldn ' t stat remote file:no such file or directory
File "/root" not found.
Sftp> quit
[Email protected] ~]#
[Email protected] ~]# stty Erase ^h
[Email protected] ~]# sftp 192.168.6.12
Connecting to 192.168.6.12 ...
[email protected] ' s password:
Sftp> Get ABC
Couldn ' t stat remote file:no such file or directory
File "/ROOT/ABC" not found.
Sftp> quit
[Email protected] ~]#
Example four when editing a file in VI press CTRL+Q to end the terminal zombie situation
[Email protected] ~]# VI 1.txt
1
2
3
Ctrl+s
~
Note: After the ctrl+s is pressed, the screen output will be banned, thus the terminal zombie situation occurs.
At this point, just press ctrl+q to end the situation because it will allow the screen to output.
Ctrl+q
Example five used with a TTY command in a bash script
In the following script, you first get the terminal file name to determine whether the script is running interactively or in the pipeline mode.
#!/bin/sh console_input=$ (TTY) echo "console_input= $CONSOLE _input" command_line= "java-xmx640m- Classpath.: lib/hyjc.jar:lib/log4j-1.2.15.jar:lib/commons-logging-1.1.1.jar:lib/proxool-0.9.0rc3.jar:lib/ Mysql-connector-java-5.1.10-bin.jar:lib/poi-3.5-zhy-20091107.jar:lib/jdom-1.1.jar Hyjc.sql.DBCLI Mhrdb.properties Mhrdb " if [" $CONSOLE _input "= =" not a TTY "] and then $COMMAND _line elif [" $ (Whereis rlwrap) " = = "Rlwrap:"]; Then stty erase ^h $COMMAND _line else rlwrap-f jdb.rlwrap $COMMAND _line fi
Transferred from: http://codingstandards.iteye.com/blog/826924
Attached: Linux terminal common shortcut keys:
Ctrl + D Deletes a character, which is equivalent to the usual delete key (the command line is equivalent to exit if there is no character ); EOF is also represented when working with multiple lines of standard input
Ctrl + H backspace deletes one character, equivalent to the usual backspace key
Ctrl + U Delete the characters before the cursor to the beginning of the line
Ctrl + K Deletes the character before the cursor to the end of the line
CTRL + C cancels the current line Input command, which is equivalent to CTRL + break
Ctrl + A cursor moves to the beginning (Ahead of Line), equivalent to the usual home key
Ctrl + e cursor moves to end of line
Ctrl + F Cursor moves forward (Forward) one character position
Ctrl + b cursor back (backward) move one character position
Ctrl + L clear screen, equivalent to execute clear command
Ctrl + P brings up the previous (Previous) command in the command history, which is equivalent to the usual up arrow
Ctrl + N brings up the next (next) command in the command history, equivalent to the usual up arrow
Ctrl + R display: Prompt to find relevant historical commands according to user input (reverse-i-search)
The Stty of Linux commands