Unix System stty Command usage detailed

Source: Internet
Author: User
Tags command line

Unix system commands a lot of, below explain Stty. This command is a common command used to change and print terminal line settings.

1, Stty (set TTY, setting TTY) command to check and modify the current registered terminal communication parameters.

The UNIX system provides an important means of controlling keyboard input and terminal output, and can set options for specific terminals or communication lines through the Stty command.

You can use-A to view the settings for the current registered terminal in the Stty command.

$ stty-a

Speed 9600 baud; Line =0;intr= del;quit = ^;erase = ^h;kill =^u; EOF = ^d;start=^q;stop=^s

-parenb-parodd CS8-CSTOPB-HUPCL cread-clocal-loblk

-IGNBRK brkint IGNPAR-PARMRK-INPCK istrip-inlcr-igncr ICRNL-IUCLC

Ixon Ixany-ixoff

Isig icanon-xcase Echo Echoe echok-echonl-noflsh

OPOST-OLCUC ONLCR-OCRNL-ONOCR onlret Ofill Ofdel tab3

As needed, the various options shown here can be reconfigured. Each terminal option has its own name (such as Ixon), most of which are either set or cleared. The option is cleared (disabled) before the corresponding option in Stty, and the option is set if there is no minus sign.

When you want to modify the values of each selection, you should correctly write the appropriate options in the Stty command. such as command

$ stty-ixon

Sets the flow control to off, and the command

$ stty Ixon

It is placed on. You can set multiple options at the same time in the Stty command:

$ stty Ixon 1200

This command sets the terminal to 1200 baud and controls the flow to on.

When the list of selected items is longer, you should be careful about the changes that cause the session to be confusing. Typically, a terminal does not work at all when it is set incorrectly. A recurring phenomenon is that the column output is displayed or the user's keystrokes cannot be properly accepted by the shell. Sometimes newline may only show or go one line but not back, that is, the newline character entered by the user cannot be read correctly by the shell. The process of establishing a new registration identity typically establishes the correct stty option, which is rarely required for daily use. However, if the variable term is not set correctly or if the user wants to use a new terminal or communication channel (such as a local area network), you need to modify the Stty option.

If you register in a machine after the terminal operation is normal, but then some confusion, then the best solution is to log off and then register to the system. Because the system will reset the appropriate options when registering. There is also a less stringent solution:

$ Stty Sane

Command sane most often appears in the collection of Stty options for most terminals. It does not change the rate of communication channel, but when the terminal is chaotic, it usually can produce beneficial effect. Command sane may cause full-screen applications (such as VI) to work correctly, and if you do not resolve any issues after you set the option sane, you should log off immediately before registering. If the terminal is still unable to work correctly after registering, the user's registration may not be successful.

If the terminal is messed up, the newline key cannot end the command line, and you can use CTRL-J instead of newline until the user executes Stty sane. At this point, and then use CTRL-J to terminate the Stty sane, so that the system back to normal.

Several key options for the Stty command are:

Option Parenb to make the terminal parity,-PARENB is prohibited checksum;

Options CS5, CS6, CS7, and Cs8 set the character size to 5, 6, 7, and 8 bits respectively;

Options 300, 600, 1200, 2400, 4800, 9600, and 19200 set the baud rate;

CSTOPB and-CSTOPB respectively set two or one stop bit;

Tabs causes the system to use tabs instead of space sequences, so that the output is reduced, and the option-tabs uses only spaces, which should be used when the terminal does not handle tabs (tab) correctly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.