Dmesg


dmesg is a command on most Unix-like operating systems that prints the message buffer of the kernel. The output of this command typically contains the messages produced by the device drivers.
On many Unix-like systems, the boot process generates a particularly dense stream of kernel messages. Many administrative issues pertain to whether a desired hardware device is successfully enumerated during the boot process, so the diagnostic process for a failed device often begins by inspecting the dmesg output from the kernel identification message to the point where the boot process concludes. Since this buffer can be overwritten by a flood of messages in subsequent operation, many Unix-like distributions store a post-boot copy of the message buffer at /var/log/dmesg or similar secure system location.
It is also common to manually consult the current dmesg buffer after hot-plugging devices, particularly USB devices, to determine whether the device has been recognized, the data rate of the port involved, what driver has been assigned, and where the device is made visible in the file system. Many distributions attempt to display device-recognition messages on the desktop, often through a taskbar pop-up, but this is not always reliable or the information presented is incomplete.
Many dmesg lines in a traditional system begin with a device name followed by a colon, followed by some detailed text. Often these come in clusters, with the same device showing up on multiple lines in succession. Each cluster is usually associated with a single device enumeration, by one particular device driver associated with the device name.
Each such driver or facility emits diagnostic information in its own chosen format, and generally includes all of the most important technical details, in a dense and arcane notation. The manual page associated with the device driver will sometimes document the message format. For example, device name da0 is a commonly seen device name associated with USB thumb drives. "da" in this case stands for "SCSI direct access". man da at the command line—without the trailing number—will bring up documentation for this driver class on many systems. Even if the precise format of the lines written to the system buffer are not described here, the parameters of interest are usually defined, though you might need to further peruse related manual pages for a complete overview spanning various hardware abstraction layers.

Booting

When initially booted, a computer system loads its kernel into memory. At this stage device drivers present in the kernel are set up to drive relevant hardware. Such drivers, as well as other elements within the kernel, may produce output reporting both the presence of modules and the values of any parameters adopted. The booting process typically happens at a speed where individual messages scroll off the top of the screen before an operator can read/digest them. The dmesg command allows the review of such messages in a controlled manner after the system has started.

After booting

Even after the system has fully booted, the kernel may occasionally produce further diagnostic messages. Common examples of when this might happen are when I/O devices encounter errors, or USB devices are hot-plugged. dmesg provides a mechanism to review these messages at a later time. When first produced they will be directed to the system console: if the console is in use then these messages may be confused with or quickly overwritten by the output of user programs.

Output

The output of dmesg can amount to many complete screens. For this reason, this output is normally reviewed using standard text-manipulation tools such as more, tail, less or grep. The output is often captured in a permanent system logfile via a logging daemon, such as syslog.