#navi(../)
* Ctrl+Sによる端末ロックを無効にする方法 [#ma47c218]
WindowsでTera Termなどのターミナルソフトでssh接続していると、思わずCtrl+S(Stop)を押して~
キー入力を受け付けないロック状態にしてしまうことがあります。~
Ctrl+Qを押せば解除されるのですが、本資料はCtrl+S自体を無効にする方法を記します。
#contents
#htmlinsertpcsp(linux_ads_top.html,linux-sp.html)
* 関連記事 [#xb78b346]
-[[端末がキー入力を受け付けなくなった場合の対処>ソフトウェア/端末がキー入力を受け付けなくなった場合の対処]]
* Ctrl+S(stop)を常に無効にする方法 [#yb70dce9]
ついつい慣れていないと押してしまうCtrl+Sという状態であれば、.bashrcに以下の構文を追記します。~
動作確認はCentOS6で行いました。
stty stop undef
catコマンドで出力した.bashrcの内容です。~
一番最後に追記しています。(ただし問題があります。問題と解決策も以下に記述してあります。)
[sakura@centos6 ~]$ cat .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
stty stop undef
これにより、Ctrl+Sで端末がロックすることはなくなります。~
bashを使用しているので、Ctrl+Sを押すとi-searchと表示されるようになります。~
&color(red){しかし困ったことにscpコマンドでファイルを設定したマシンに対してコピーすると以下のようなエラーが発生してしまいます。};~
この問題に対する対処方法は、以下に記します。
[sakura@centos6 ~]$ scp file localhost:
sakura@localhost's password:
stty: 標準入力: 無効な引数です
file 100% 2 0.0KB/s 00:00
scpのエラー回避策は、接続後に端末でstty stop undefを入力し設定するか、以下のように.bashrcを設定します。~
参考記事 : [[scpができなくなった時の対処法・bashrc編>Linux環境設定/scpができなくなった時の対処法・bashrc編]]
上記では最後に以下の1行を追記しました。
stty stop undef
これを以下のように変更します。
if [ "$SSH_TTY" != "" ]; then
stty stop undef
fi
catコマンドで出力した.bashrcの内容です。~
[sakura@centos6 ~]$ cat .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
if [ "$SSH_TTY" != "" ]; then
stty stop undef
fi
* Ctrl + s とCtrl + q [#z9200716]
sttyコマンドでキーに割り当てられている動作を確認してみます。~
以下、stty -a で出力した結果です。
[sakura@centos6 ~]$ stty -a
speed 9600 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^H; 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
上記の出力をみると、以下の記述が表示されています。~
''^''はCtrlになります。
start = ^Q; stop = ^S
つまり、Ctrl+Sはstop, Ctrl+Qはstartになります。
以上、Ctrl+Sによる端末ロックを無効にする方法でした。
#htmlinsertpcsp(linux_ads_btm.html,linux-sp.html)