けけずんセルフハッキング

エンジニアっぽい雰囲気を醸しだしているかのようなブログです!

/bin/stty で端末設定を設定 or 表示する

はじめに

よく分からんコマンド調べてみようシリーズ。 経緯はこちら。

kkznch.hatenablog.com

今回は /bin/stty について。

/bin/stty

確実に一回も実行したことないであろうコマンド。 stty だからコンソールに関連するコマンドかな。

こちら man stty したときの DESCRIPTION の内容。

The stty utility sets or reports on terminal characteristics for the device that is its standard input. If no options or operands are specified, it reports the settings of a subset of characteristics as well as additional ones if they differ from their default values. Otherwise it modifies the terminal state according to the specified arguments. Some combinations of arguments are mutually exclusive on some terminal types.

標準入力であるデバイスの端末特性を設定したり表示したりする、何を言っているのかよく分からない。

とりあえず実行して動きを見る。

/bin/stty 実行してみる

よし何が起きるのか分からんけど実行する。

$ /bin/stty
speed 38400 baud;
lflags: echoe echok echoke echoctl pendin
iflags: iutf8
oflags: -oxtabs
cflags: cs8 -parenb
erase
^H

実行したけど何が起きたのか分からなかった。 端末の転送速度とか特殊文字に関する設定が出力されてるだけかな。

linuxjm.osdn.jp

ここを見るに、文字を削除したときやプロセスをkillしたときの表示形式などが出力されてるっぽい。 ほぼ触ることがなさそうなコマンドだ...。

ちなみにコンソールの表示がおかしくなったときは stty の設定がおかしくなってる可能性があるので、以下のコマンドを実行して stty の設定を初期化してあげるとよいらしい。

$ stty sane

qiita.com