Diagnosing problems with dmesg and /var/log/messages

When you're having hardware problems, or just trying to work out why something's not working under Linux, or any Unix-like operating system, logs can be invaluable sources of information.

Specific applications (like the Apache web server, for example) will often keep their own log files, but there are also system-wide logs that can help you as a power user or an administrator to track down issues.

First of all, if it's a hardware problem you're having, then check out dmesg. From the man page:

dmesg - print or control the kernel ring buffer

To invoke dmesg, simply type it at a terminal:

$ dmesg

Often there can be quite a lot of output, so to only show the last 10 lines, pipe the output to tail, like so:

$ dmesg | tail

That usually throws up some useful information if you're having a hardware issue. Even if you're not a power user and you're seeking help, posting the output of dmesg | tail can help anyone who's helping you to diagnose the problem.

And finally, there is also the /var/log/messages file. This often contains more software-specific errors or warnings, but is equally useful in trying to figure out why something isn't working.

Usually you need to be root to read the file, so you'll need to either run su - in your terminal first, or prefix the command with sudo.

# tail /var/log/messages

That will show you the last 10 lines of the file. If you want to see the whole thing, you can use other commands on the /var/log/messages file (like cat or perhaps less if you want to scroll through it).

So next time you need to ask someone help with your Linux problem, give them the output of these two commands and it might speed up your solution!

Avatar for peter Peter Upfold - http://peter.upfold.org.uk/

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

Home » Articles »

Discussion: Diagnosing problems with dmesg and /var/log/messages

Home » Articles » Diagnosing problems with dmesg and /var/log/messages