dmesg【コマンド】
コマンドだよ
UNIX系で使えるよ
カーネルが出力した情報を表示するよ
簡単に書くよ
dmesg【コマンド】とは
コンピュータさんに対する命令文(コマンド)のひとつ
であり
カーネル
(OSの中核として頑張っているソフトウェア)が出力した情報を確認するときに使うコマンド
です。
詳しく書くよ
順番に見ていきましょう。
まずは予備知識として「OS」と「カーネル」について簡単に説明します。
「そんなの説明されなくても知ってるよ!」な人は適当に読み飛ばしてください。
OSは「パソコンさんの人格に相当するソフト」です。
パソコンさんは中にOSを入れることで、はじめてパソコンとしての お仕事が できます。
「これが無いとパソコンじゃねーよ」な基本ソフトです。
※「OS」という用語が世間に広まった きっかけがパソコンなので「パソコン」と書きましたが、スマホや その他のコンピュータ類でも同じです。
カーネルは「OSの中核部分として頑張っているソフトウェア」です。
OSを1つの組織と見なした場合、カーネルさんは中心人物です。
こいつがいないと始まりません。
ただし、カーネルさんだけでは組織の運営が成り立ちません。
シェルやデーモンといった、その他のソフトウェアを手足のように使うことによって、はじめて組織が回ります。
「カーネルさんは大事なやつだけど、カーネルさんだけではOSは成り立たない」と理解してください。
カーネルさんと あれやこれやのソフトウェアが組み合わさって、1つのOSが出来あがっているのです。
カーネルさんは、何か特別なことが起こると「こんなことがあったよ!」という情報を出力します。
出力された情報は、とあるところにメモられています。
以上を踏まえて
カーネルさんが出力した情報を確認するときに使うコマンド
が「dmesg」コマンドです。
「dmesg」コマンドはUNIX系(LinuxとかMacとか)で使えます。
書き方は
dmesg [オプション]
です。
オプションは、あれやこれやとあります。
| オプション | 説明 |
|---|---|
| -C | メモった情報を消す Clear the ring buffer. |
| --clear | メモった情報を消す Clear the ring buffer. |
| -c | 表示した後、メモった情報を消す Clear the ring buffer. |
| --read-clear | 表示した後、メモった情報を消す Clear the ring buffer. |
| -D | 情報を画面上に表示しない。何の意味があるんだ?これ Disable printing messages to the console. |
| --console-off | 情報を画面上に表示しない。何の意味があるんだ?これ Disable printing messages to the console. |
| -d | 何が変わるのか、よく分からなかった Display the timestamp and time delta spent between messages.If used together with --notime then only the time delta without the timestamp is printed. |
| --show-delta | 何が変わるのか、よく分からなかった Display the timestamp and time delta spent between messages.If used together with --notime then only the time delta without the timestamp is printed. |
| -e | 最終行に実行日?が表示された Display the local time and delta in human readable format. |
| --reltime | 最終行に実行日?が表示された Display the local time and delta in human readable format. |
| -E | 情報を画面上に表示する Enable printing messages to the console. |
| --console-on | 情報を画面上に表示する Enable printing messages to the console. |
| -F 【ファイル名】 | ファイルから情報を読み込む? Read log from file. |
| --file 【ファイル名】 | ファイルから情報を読み込む? Read log from file. |
| -f 【リスト】 | うんちゃらかんちゃら Restrict output to defined (comma separated) list of facilities. |
| --facility 【リスト】 | うんちゃらかんちゃら Restrict output to defined (comma separated) list of facilities. |
| -H | 色付けたりして、人間様が見やすいように表示してやるよ! Enable human readable output. See also --color, --reltime and --nopager. |
| --human | 色付けたりして、人間様が見やすいように表示してやるよ! Enable human readable output. See also --color, --reltime and --nopager. |
| -h | ヘルプを表示する Print a help text and exit. |
| --help | ヘルプを表示する Print a help text and exit. |
| -k | カーネルの情報を表示する。あれ?おまえって最初からカーネルの情報を表示するコマンドじゃないの? Print kernel messages. |
| --kernel | カーネルの情報を表示する。あれ?おまえって最初からカーネルの情報を表示するコマンドじゃないの? Print kernel messages. |
| -L | 大事なところには色を付けて表示してやるよ!感謝しろよな Colorize important messages. |
| --color | 大事なところには色を付けて表示してやるよ!感謝しろよな Colorize important messages. |
| -l 【リスト】 | エラーとか、警告とか、表示する情報の種類を指定する Restrict output to defined (comma separated) list of levels. |
| --level 【リスト】 | エラーとか、警告とか、表示する情報の種類を指定する Restrict output to defined (comma separated) list of levels. |
| -n 【レベル】 | うんちゃらかんちゃら Set the level at which logging of messages is done to the console. The level is a level number or abbreviation of the level name. For all supported levels see dmesg --help output. |
| --console-level 【レベル】 | うんちゃらかんちゃら Set the level at which logging of messages is done to the console. The level is a level number or abbreviation of the level name. For all supported levels see dmesg --help output. |
| -P | 「-H(--human)」オプションを指定するとページ送り機能が有効になるんだけどよ~。そのページ送り機能を無効にしたるわ。 Do not pipe output into a pager, the pager is enabled for --human output. |
| --nopager | 「-H(--human)」オプションを指定するとページ送り機能が有効になるんだけどよ~。そのページ送り機能を無効にしたるわ。 Do not pipe output into a pager, the pager is enabled for --human output. |
| -r | 行の先頭に変な数字が付いたよ Print the raw message buffer, i.e., do not strip the log level prefixes. |
| --raw | 行の先頭に変な数字が付いたよ Print the raw message buffer, i.e., do not strip the log level prefixes. |
| -S | syslogうんちゃら Force to use syslog(2) kernel interface to read kernel messages. The default is to use /dev/kmsg rather than syslog(2) since kernel 3.5.0. |
| --syslog | syslogかんちゃら Force to use syslog(2) kernel interface to read kernel messages. The default is to use /dev/kmsg rather than syslog(2) since kernel 3.5.0. |
| -s 【サイズ】 | 指定しても、なんか変わらなかった Use a buffer of size to query the kernel ring buffer. |
| --buffer-size 【サイズ】 | 指定しても、なんか変わらなかった Use a buffer of size to query the kernel ring buffer. |
| -T | 日付を「年月日時分秒」の形式で表示してやるよ Use a buffer of size to query the kernel ring buffer. |
| --ctime | 日付を「年月日時分秒」の形式で表示してやるよ Use a buffer of size to query the kernel ring buffer. |
| -t | 日付を表示しないよ Do not print kernel's timestamps. |
| --notime | 日付を表示しないよ Do not print kernel's timestamps. |
| -u | ユーザ領域の情報も表示するよ。ユーザ領域って何? Print userspace messages. |
| --userspace | ユーザ領域の情報も表示するよ。ユーザ領域って何? Print userspace messages. |
| -V | バージョン情報を表示する Output version information and exit. |
| --version | バージョン情報を表示する Output version information and exit. |
| -w | 新しい情報が出力されるのを待ってるぜ! Wait for new messages. |
| --follow | 新しい情報が出力されるのを待ってるぜ! Wait for new messages. |
| -w | 新しい情報が出力されるのを待ってるぜ! Wait for new messages. |
| -x | 「facility」や「level(priority)number」を人間様が読みやすい形式で表示してやるぜ Decode facility and level (priority) number to human readable prefixes. |
| --decode | 「facility」や「level(priority)number」を人間様が読みやすい形式で表示してやるぜ Decode facility and level (priority) number to human readable prefixes. |
などです。
オプションがたくさんありますが、あまり気にする必要は ありません。
オプションを付けないで
dmesg
のように指定しても普通に使えます。
あっ、ずらずらっとたくさん表示されるので、例えば
dmesg | more
のようにして、1ページずつ見た方が良いとは思いますけどね。
あと使うとすれば「-T」オプションでしょうか。
私の環境(CentOS 7)の場合ですが、「-T」オプションを指定して
dmesg -T
のように書くと、初期状態では
[ 46.367065] cfg80211: Exceeded CRDA call max attempts. Not calling CRDA
[ 47.950134] cfg80211: Exceeded CRDA call max attempts. Not calling CRDA
[ 219.437586] SELinux: initialized (dev tmpfs, type tmpfs), uses transition SIDs
のような見た目だったのが
[日 1月 3 07:48:24 2016] cfg80211: Exceeded CRDA call max attempts. Not calling CRDA
[日 1月 3 07:48:25 2016] cfg80211: Exceeded CRDA call max attempts. Not calling CRDA
[日 1月 3 07:51:17 2016] SELinux: initialized (dev tmpfs, type tmpfs), uses transition SIDs
に変わりました。
日付部分が読みやすくなっていますよね。
これだけ覚えておけば、とりあえずは使えると思います。
あとは必要に応じて、お勉強してください。
一言でまとめるよ
まぁ「dmesg」ってコマンドが出てきたら「カーネル
(OSの中核として頑張っているソフトウェア)が出力した情報を確認するときに使うんだな~」と お考えください。
おまけ
■訳してみるよ
「d」は多分「display(ディスプレイ)」の略です。
「display(ディスプレイ)」の意味は「展示する」とか「表示する」とか「展示」とか「展示品」とか「(コンピュータとかの)ディスプレイ」とかです。
「mesg」は多分「message(メッセージ)」の略です。
「message(メッセージ)」の意味は「伝言」とか「伝達」とか「連絡」とかです。
何となく くっつけると
伝言を表示する
となります。
■検索してみる?






