How To Get Hardware Specs of Your System Using lshw Hardware Lister

by Ramesh Natarajan on December 22, 2008

Hardware Specs
Photo courtesy of viagallery.com

This is a guest post written by SathiyaMoorthy.

lshw (Hardware Lister) command gives a comprehensive report about all hardware in your system. This displays detailed information about manufacturer, serial number of the system, motherboard, CPU, RAM, PCI cards, disks, network card etc.,

Using lshw, you can get information about the hardware without touching a screwdriver to open the server chassis. This is also very helpful when the server is located in a remote data center, where you don’t have physical access to the server.

In our previous article, we discussed about how to display hardware information on linux using dmidecode command. In this article, let us review how to view the hardware specifications using lshw command.

Download lshw

Download the latest version of lshw from Hardware Lister website. Extract the source code to the /usr/src as shown below.

# cd /usr/src
# wget http://ezix.org/software/files/lshw-B.02.13.tar.gz
# gzip -d lshw-B.02.13.tar.gz
# tar xvf lshw-B.02.13.tar


Note: To install the pre-compiled version, download it from Hardware Lister website.

Install lshw

Install lshw as shown below. This will install lshw in the /usr/sbin directory.

# make

# make install
make -C src install
make[1]: Entering directory `/usr/src/lshw-B.02.13/src'
make -C core all
make[2]: Entering directory `/usr/src/lshw-B.02.13/src/core'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/src/lshw-B.02.13/src/core'
g++ -L./core/ -g -Wl,--as-needed -o lshw lshw.o -llshw -lresolv
install -p -d -m 0755 ///usr/sbin
install -p -m 0755 lshw ///usr/sbin
install -p -d -m 0755 ///usr/share/man/man1
install -p -m 0644 lshw.1 ///usr/share/man/man1
install -p -d -m 0755 ///usr/share/lshw
install -p -m 0644 pci.ids usb.ids oui.txt manuf.txt ///usr/share/lshw
make[1]: Leaving directory `/usr/src/lshw-B.02.13/src'

lshw Output Layout

When executing lshw without option, you will get detailed information on the hardware configuration of the machine in text format. Following is the structure of lshw output.

system information
   motherboard information
     cpu information
	cache, logical cpu
     memory
	capacity, total size, individual bank information
     pci slot information
     ide slot information
	disk information
		total size, partition,
     usb slot information
    network


Following is the partial output of lshw command.

# lshw | head
local-host
    description: Rack Mount Chassis
    product: PowerEdge 2850
    vendor: Dell Computer Corporation
    serial: 1234567
    width: 32 bits
    capabilities: smbios-2.3 dmi-2.3 smp-1.4 smp
    configuration: boot=normal chassis=rackmount cpus=2 uuid=12345
  *-core
       description: Motherboard


Note: lshw must be run as root to get a full report. lshw will display partial report with a warning message as shown below when you execute it from a non-root user.

jsmith@local-host ~> /usr/sbin/lshw
WARNING: you should run this program as super-user.

lshw Classes

To get information about a specific hardware, you can use -class option. Following classes can be used with the -class option in the lshw command.

address
bridge
bus
communication
disk
display
generic
input
memory
multimedia
network
power
printer
processor
storage
system
tape
volume

Get Information about the Disks using lshw

The example below will display all the information about the disks on the system. This indicates that the /dev/sda is a SCSI Disk, RAID1 configuration with a total capacity of 68G.

# lshw -class disk
  *-disk
       description: SCSI Disk
       product: LD 0 RAID1   69G
       vendor: MegaRAID
       physical id: 2.0.0
       bus info: scsi@0:2.0.0
       logical name: /dev/sda
       version: 516A
       size: 68GiB (73GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=2 signature=000e1213

Get Information about Physical Memory (RAM) of the System

Please note that only partial output is shown below.

# lshw -class memory

        *-memory
      description: System Memory
      size: 512MB
      capacity: 2GB

	*-bank:8
     description: DIMM Synchronous [empty]
	*-bank:9
     description: DIMM Synchronous
	size: 512MB
     width: 32 bits

Generate Compact Hardware Report Using lshw

By default lshw command generates multi-page detailed report. To generate a compact report use -short option as shown below. Only partial output is shown below.

# lshw -short
H/W path              Device     Class      Description
=======================================================
                                 system     PowerEdge 2850
/0                               bus        12345
/0/0                             memory     64KiB BIOS
/0/400                           processor  Intel(R) Xeon(TM) CPU 3.40GHz
/0/400/700                       memory     16KiB L1 cache
/0/400/701                       memory     1MiB L2 cache
/0/400/702                       memory     L3 cache
/0/400/1.1                       processor  Logical CPU
/0/1000                          memory     4GiB System Memory
/0/1000/0                        memory     1GiB DIMM Synchronous 400 MHz (2.5 ns)
/0/1000/1                        memory     1GiB DIMM Synchronous 400 MHz (2.5 ns)
/0/100/6/0/4          eth2       network    82546EB Gigabit Ethernet Controller (Copper)
/0/100/6/0/4.1        eth3       network    82546EB Gigabit Ethernet Controller (Copper)
/0/100/6/0.2                     bridge     6700PXH PCI Express-to-PCI Bridge B
/0/100/6/0.2/2                   bus        Thor LightPulse Fibre Channel Host Adapter
/0/100/1e                        bridge     82801 PCI Bridge
/0/100/1e/d                      display    Radeon RV100 QY [Radeon 7000/VE]

Generate HTML or XML Hardware Report Using lshw

You can generate a HTML or XML output from the lshw command directly as shown below.

# lshw -html > hwinfo.html
# lshw -xml > hwinfo.xml


This article was written by SathiyaMoorthy, developer of enterprise postgres query analyser, an efficient tool for parsing postgresql log to generate html report, which can be used for fine tuning the postgres settings, and sql queries. The Geek Stuff welcomes your tips and guest articles.


Linux Sysadmin Course Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.
Get the Linux Sysadmin Course Now!

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 3 comments… read them below or add one }

1 deep-unix December 28, 2008 at 10:51 pm

your posting is excellent.

2 Suresh.G December 27, 2010 at 8:05 am

Absolutely Fantastic.

3 niraj February 13, 2012 at 11:31 pm

Its always a question in linux how to check the H/w list just like windows
through this we can easily do the same.

Leave a Comment

Previous post:

Next post: