「分かりそう」で「分からない」でも「分かった」気になれるIT用語辞典イメージぴよ画像「分かりそう」で「分からない」でも「分かった」気になれるIT用語辞典

dmesg【コマンド】

pointこの用語のポイント

pointコマンドだよ

pointUNIX系で使えるよ

pointカーネルが出力した情報を表示するよ

スポンサーリンク

簡単に書くよ

dmesg【コマンド】とは

コンピュータさんに対する命令文(コマンド)のひとつ
であり

カーネル(OSの中核として頑張っているソフトウェア)が出力した情報を確認するときに使うコマンド
です。


image piyo

詳しく書くよ

順番に見ていきましょう。
まずは予備知識として「OS」と「カーネル」について簡単に説明します。
「そんなの説明されなくても知ってるよ!」な人は適当に読み飛ばしてください。

OSは「パソコンさんの人格に相当するソフト」です。
パソコンさんは中にOSを入れることで、はじめてパソコンとしての お仕事が できます。
「これが無いとパソコンじゃねーよ」な基本ソフトです。

dmesg

※「OS」という用語が世間に広まった きっかけがパソコンなので「パソコン」と書きましたが、スマホや その他のコンピュータ類でも同じです。

カーネルは「OSの中核部分として頑張っているソフトウェア」です。
OSを1つの組織と見なした場合、カーネルさんは中心人物です。
こいつがいないと始まりません。

dmesg2

ただし、カーネルさんだけでは組織の運営が成り立ちません。
シェルデーモンといった、その他のソフトウェアを手足のように使うことによって、はじめて組織が回ります。

「カーネルさんは大事なやつだけど、カーネルさんだけではOSは成り立たない」と理解してください。
カーネルさんと あれやこれやのソフトウェアが組み合わさって、1つのOSが出来あがっているのです。

dmesg3

カーネルさんは、何か特別なことが起こると「こんなことがあったよ!」という情報を出力します。
出力された情報は、とあるところにメモられています。

dmesg4

以上を踏まえて

カーネルさんが出力した情報を確認するときに使うコマンド

が「dmesg」コマンドです。
「dmesg」コマンドはUNIXLinuxとか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.
-Ssyslogうんちゃら
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.
--syslogsyslogかんちゃら
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


に変わりました。
日付部分が読みやすくなっていますよね。

これだけ覚えておけば、とりあえずは使えると思います。
あとは必要に応じて、お勉強してください。


image piyo2

一言でまとめるよ

まぁ「dmesg」ってコマンドが出てきたら「カーネル(OSの中核として頑張っているソフトウェア)が出力した情報を確認するときに使うんだな~」と お考えください。

一番上に戻るよ
スポンサーリンク
書籍画像058
書籍画像049

おまけ

■訳してみるよ

「d」は多分「display(ディスプレイ)」の略です。
「display(ディスプレイ)」の意味は「展示する」とか「表示する」とか「展示」とか「展示品」とか「(コンピュータとかの)ディスプレイ」とかです。
「mesg」は多分「message(メッセージ)」の略です。
「message(メッセージ)」の意味は「伝言」とか「伝達」とか「連絡」とかです。
何となく くっつけると

伝言を表示する

となります。


■検索してみる?




書籍画像
わわわ説明術コラム
宣伝だよ
エンジニア育成現場の「失敗」集めてみた。 42の失敗事例で学ぶマネジメントのうまい進めかた
「分かった!」と思わせる説明の技術 知識ゼロの相手にも伝わるようになる本【Audible】
AI用語図鑑 ビジネス・開発・試験対策に使える厳選キーワード256