lshw command – List hardware information in Linux

lshw is a Linux command which provides details of all the hardware in your PC. The details provided by the lshw command run the gamut of processors, memory, slots, onboard sound, video chipset and more. To get the full details of your hardware, you need to run lshw command as root (or super user). If you are using Ubuntu or any of its derivatives, you can run it using sudo as follows :

$ sudo lshw

The output of lshw contain copious amounts of information about every aspects of your pc hardware. If you feel overwhelmed by the sheer amount of details, you can use the option -short to get an abridged version of the output.

$ sudo lshw -short

The output of the above lshw command on my machine is as follows :

H/W path               Device      Class       Description
                                   system      INTEL
/0                                 bus         DG31PR
/0/0                               memory      64KiB BIOS
/0/4                               processor   Intel(R) Core(TM)2 Duo CPU     E7300  @ 2.66GHz
/0/4/5                             memory      32KiB L1 cache
/0/4/6                             memory      3MiB L2 cache
/0/4/1.1                           processor   Logical CPU
/0/4/1.2                           processor   Logical CPU
/0/22                              memory      2GiB System Memory
/0/22/0                            memory      2GiB DIMM DDR Synchronous 800 MHz (1.2 ns)
--- Truncated for brevity ---

As you can see in the preceeding output, lshw classifies different parts of the hardware using classes. So if you want to see only the information related to a particular class such as memory, you can run the lshw command using the -class option as follows :

$ sudo lshw -class memory

… which will provide you detailed specifications  about your computer’s memory and little else.

To get a list of all the classes identified by lshw, you can execute  it using the -businfo option.

Get lshw output in multiple formats

lshw command provides output in multiple file formats. For example, you can get the output in HTML, XML, text and a few more.
For instance, to get the output in HTML, you use the -html option as follows :

$ sudo lshw -html > hardware-info.html

… And it presents the output in a nice HTML format.

lshw output in HTML format

lshw GUI

The lshw command also has an equivalent GUI  which is available as the lshw-gtk package in Debian based Linux distributions. In Ubuntu, you can install lshw GUI as follows :

$ sudo apt-get install lshw-gtk
lshw gtk front-ent

This GUI tool provides all the details in a very user friendly and structured manner which any lay person can understand.

To sum up, identifying all the PC hardware in Linux such as  processors, memory, chipset,  audio and video is made easy using the lshw command.