的作用了解Linux系统中stty的功能(linux中stty)

Linux系统中stty是一个实用程序,它可以用于检查和设置终端(terminal)设备的控制模式。stty的主要作用是控制与终端的交互,如改变特殊字符的键映射,改变功能键的功能行为,改变终端的缓冲模式和超时设置,设置滚动区等。

通常,对于非绑定的终端设备,使用stty -a可以查看当前设备的全部设置。例如:

“`shell

[root@localhost ~]# stty -a

speed 38400 baud; rows 24; columns 80; 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; discard = ^O; min = 1; time = 0;

-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts

-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


上述命令的输出显示了当前设备的设置,包括:行数(rows),列数(columns),终端模式(line),特殊字符映射(intr),功能键的功能行为(lnext),输入超时(time),缓冲模式(min),安全功能(isc),控制选项(icanon),字符调整(iexten)等。

此外,stty还可以用于更改终端设备的当前设置,例如更改特殊字符的重映射:

```shell
[root@localhost ~]# stty intr a
[root@localhost ~]# stty -a
speed 38400 baud; rows 24; columns 80; line = 0;
intr = A; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ;
eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z;
rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-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

以上仅为stty实用程序的一些主要功能,更多内容可参阅stty命令的详细用法。总之,stty实用程序起着重要的作用,能帮助用户更好的了解终端的控制模式,并对其设置进行定制和调整。


数据运维技术 » 的作用了解Linux系统中stty的功能(linux中stty)