To answer at least the first part of your question about dmesg
:
/var/log/dmesg
stores the content of the 'kernel ring buffer', a memory buffer created by the kernel at boot in which to store log data it generates as soon as you get past the bootloader phase.
A ring buffer is a special kind of buffer that is always a constant size, removing the oldest messages when new messages come in.
The text stored in the kernel ring buffer is what you see flashing past you on-screen when you first boot a Unix-like machine in console mode (no splash screen, Plymouth). The kernel log is stored in a memory buffer so that boot logs have somewhere to be, until the system has bootstrapped itself to the point where the syslog
daemon can take over.
dmesg
under Linux is a part of the essential util-linux
package of system maintenance tools published by kernel.org. According to the dmesg(1)
man page,
dmesg is used to examine or control the kernel ring buffer.
See: http://www.computerhope.com/unix/dmesg.htm
Under 'systemd' init, this command can be used to print the kernel ring buffer:
# journalctl --dmesg or journalctl -k
, thxs for correction @don_crissti
Issuing the command dmesg | grep -i ethernet
for example, will parse the kernel ring buffer for the string 'ethernet'.
I hope this helps at least with the first part of your inquiry.