Hardware information in Linux
It can be a real pain trying to find detailed hardware information in Linux when you don’t know what tools to use. I will try and outline a few tools that are typically pre-installed in many Linux distributions, as well as show you where to find information stored on your computer using the cat command to output the information. What brought up the idea of this blog post stems from a conversation I had at work a few days ago. How does one of our customers know for a fact he/she has the hardware that they are paying for?
First off, what processor(s) is your system running?
cat /proc/cpuinfo
I know, it can be intimidating the first time you look at the output. I will point out a few details to get you started! vendor_id will tell you the manufacturer of your processor, for example, GenuineIntel. Next, model name such as Intel(R) Xeon(TM) CPU 3.00GHz. A few other descriptors to mention are the cpu MHz ie: 3000.313 (which in my case is technically a part of the model name), and cache size such as 2048 KB. One thing to note, as in my case; having a hyper-threaded processor, it will show up as two processors. The same is true for multi-core processors, one “processor” designation per core.
Next, let’s verify our partitioning scheme is how it should be!
cat /proc/partitions
The output looks very cryptic, I know. So, let’s try something a little nicer, shall we?
df -h
Much easier on the eyes! df stands for disk free and by looking at the output, it is pretty obvious as to why. To clarify, the -h flag is to format the size output in human readable format.
Let’s move onto memory:
cat /proc/meminfo
Ouch, that looks pretty nasty too, doesn’t it? Let’s try something a little easier to digest!
free -m
The free command will print the total amount of free and used physical memory in the system. Another use of the tool is to use it like so:
free -mt
This will now show you the total amount of free and used physical memory, and swap.
Now for the nitty-gritty! Time to get to the meat and potato’s. We are going to list all the PCI devices with the following command:
lspci
Per the lspci man page, lspci is a utility for displaying information about all PCI buses in the system and all devices connected to them. To get a quick, not so detailed list, try this:
lspci -short
Now, if you are feeling brave, you can get a very detailed look at the same information by telling lspci to be verbose:
lspci -vvv
I highly recommend reading the man page, and doing some more searching on this command.
For those of you who want all the information possible in one command, I recommend:
lshw
Per the man page, lshw is a small tool to extract detailed information on the hardware configuration of the machine. It can report exact memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed, etc. on DMI-capable x86 or IA-64 systems and on some PowerPC machines (PowerMac G4 is known to work).
This wraps up my post, I hope it helps some of you out there. I would love to hear from anyone with any comments or even suggestions on other tools out there!
We wrote some tools on top of dmidecode to extract hardware information and report it back to us. By far the hardest information to extract is that about RAID controllers since every vendor has one (or many) proprietary tools required to gather this information.
I actually have dmidecode in my “todo list” for a future blog post! I just need to find time to craft something together! I agree with you on the RAID controller CLI tools. They sure can seem cryptic, that’s for sure! That might be something else I can put together in the future!