The Linux kernel is a complex piece of engineering. From boot-up to runlevel 5 multi-user mode, the Linux kernel initializes and manages a PC’s resources including the processor, the memory, the networking, the video output, and the local storage. As the kernel works with all these different subsystems and resources, it logs various high-level messages to let system admins know what it is doing. These messages can be viewed using the “dmesg” command. The problem is that the output from the kernel can seem complex and unintelligible to the untrained eye. However, with a little help understanding the basics, the “dmesg” command can become a very powerful tool in a system admin’s tool-set.

Boot

The quickest way to learn about kernel messages is to examine the first few lines from the boot process. To view the first page of output, use the following command:

The first three lines are likely about the initialization of the “Control Groups” for the processor. These aren’t that interesting unless you are a kernel hacker. However, the next line is very important. It will tell you what version of the Linux kernel you are running.

The output on my test machine reads:

What this tells me is that my test machine is running Linux kernel 3.13 which was compiled by Ubuntu on April 10 2014.

The next 80 to 100 lines are all low level details about the BIOS, the CPU and the memory. The next important line is the summary of the system memory. It always starts with “Memory:”. On my test machine, the output is:

The number after the slash is the total amount of system memory accessible to the Linux kernel, in this case 1.5GB. At this point, Linux has almost finished looking at the processor and memory, and it will soon turn its attention to the rest of the machine including the video, the USB ports, the hard disks and so on.

Hardware detection

The kernel output is also a great way to discover how Linux is interacting with the hardware in your PC. For example, to discover which hard disks the kernel recognizes, you can search through the messages for the keyword “sda”. To do this, use “grep” like this:

“sda” is the name given to the first SATA hard disk, “sdb” is the second SATA hard disk and so on. If you don’t find your disks under “sda”, “sdb” etc., try “hda”, “hdb” and so on.

To get information on the network card, search for “eth0”, for example:

On my test machine, one of the lines of “eth0” related output shows:

This tells me that my Ethernet card is an Intel PRO/1000 (known as an e1000).

If you insert a USB flash drive and you want to check if it has been recognized by the kernel and what device name it has been assigned to, you can see the last few kernel messages using tail:

The -20 tells tail to show the last 20 lines of output from dmesg. The example output shows that a flash drive make by ADATA was inserted into the USB port, it has a capacity of 8GB and that it has been assigned the device name of sdd.

dmesg can be a very useful tool for system admins. Give it a try and see what you can learn about your system. If you have any questions, please ask them in the comments section, and we will see if we can help.

Gary has been a technical writer, author and blogger since 2003. He is an expert in open source systems (including Linux), system administration, system security and networking protocols. He also knows several programming languages, as he was previously a software engineer for 10 years. He has a Bachelor of Science in business information systems from a UK University.

Our latest tutorials delivered straight to your inbox