Selected Reading

lshw command in Linux with Examples



Name

lshw - list hardware

Synopsis

lshw [ -version ]

lshw [ -help ]

lshw [ -X ]

lshw  [   [ -html ]  [ -short ]  [ -xml ]  [ -json ]  [ -businfo ]  ]  [ -dump filename ] [ -class class... ]  [ -disable test... ]  [ -enable test... ]  [ -sanitize ]  [ -numeric ]  [ -quiet ]

Description

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). It does so by reading different files in the /proc directory.

It currently supports standard hardware interfaces like DMI (x86 and IA-64 only), OpenFirmware device tree (PowerPC only), PCI/AGP, CPUID (x86), IDE/ATA/ATAPI, PCMCIA (only tested on x86), SCSI and USB.

Options

The options for lshw commands are:

-version
   Displays the version of lshw and exits.

-help  Displays the available command line options and quits.

-X     Launch the X11 GUI (if available).

-html  Outputs the device tree as an HTML page.

-xml   Outputs the device tree as an XML tree.

-json  Outputs the device tree as a JSON object (JavaScript Object Notation).

-short Outputs  the  device tree showing hardware paths, very much like the output of HP-UX's ioscan.

-businfo
   Outputs the device list showing bus information, detailing SCSI, USB, IDE and  PCI addresses.

-dump filename
   Dump collected information into a file (SQLite database).

-class class
   Only  show  the  given  class of hardware. class can be found using lshw -short or lshw -businfo.

-C class
   Alias for -class class.

-enable test

-disable test
   Enables or disables a test. test can be dmi (for DMI/SMBIOS  extensions), device tree (for OpenFirmware device tree), spd (for memory Serial Presence Detect), memory (for memory-size guessing heuristics), cpuinfo (for kernel-reported CPU detection), cpuid  (for CPU detection), pci (for PCI/AGP access), isapnp (for ISA PnP extensions), pcmcia (for  PCMCIA/PCCARD), ide (for IDE/ATAPI), usb  (for USB devices),scsi (for SCSI) or network (for network interfaces detection).

-quiet Don't display status.

-sanitize
   Remove potentially sensitive information from output (IP addresses, serial numbers, etc.).

-numeric
   Also display numeric IDs (for PCI and USB devices).

Examples

1. Without any option lshw command would generate a detailed information report about all detected hardware. It would generate a big output with quite a lot of technical details. lshw command assorts hardware components into groups called "class". Processor, memory, display, network, storage are all different classes.

The lshw command should be run with super privileges to be able to detect and report the maximum amount of information. So run as root, or use sudo.

$ sudo lshw
erpnext                   
   description: Desktop Computer
   product: (To be filled by O.E.M.)
   width: 64 bits
   capabilities: smbios-2.7 dmi-2.7 vsyscall32
   configuration: boot=normal chassis=desktop family=To be filled by O.E.M. sku=To be filled by O.E.M. uuid=04C9C13F-C899-11E2-9FFF-6431503407E9
   *-core
      description: Motherboard
      product: DH61WW
      vendor: Intel Corporation
      physical id: 0
      version: AAG23116-303
      serial: BTWW322008V5
   *-firmware
      description: BIOS
      vendor: Intel Corp.
      physical id: 0
      version: BEH6110H.86A.0109.2012.1221.1455
      date: 12/21/2012
      size: 64KiB
      capacity: 4032KiB
...

We can see, it is a long list of information.

2. We can use -short option along with lshw command to list all hardware components/configuration in a compact format.

$ lshw -short
WARNING: you should run this program as super-user.
H/W path     Device           Class          Description
========================================================
                              system         Computer
/0                            bus            Motherboard
/0/0                          memory         7814MiB System memory
/0/1                          processor      Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
/0/100                        bridge         Xeon E3-1200 v2/3rd Gen Core processor DRAM Controller
/0/100/2                      display        Xeon E3-1200 v2/3rd Gen Core processor Graphics Contro
/0/100/16                     communication  6 Series/C200 Series Chipset Family MEI Controller #1
/0/100/19    enp0s25          network        82579V Gigabit Network Connection
/0/100/1a                     bus            6 Series/C200 Series Chipset Family USB Enhanced Host 
/0/100/1b                     multimedia     6 Series/C200 Series Chipset Family High Definition Au
/0/100/1c                     bridge         6 Series/C200 Series Chipset Family PCI Express Root P
/0/100/1c/0                   bridge         IT8892E PCIe to PCI Bridge
/0/100/1d                     bus            6 Series/C200 Series Chipset Family USB Enhanced Host 
/0/100/1f                     bridge         H61 Express Chipset LPC Controller
/0/100/1f.2                   storage        6 Series/C200 Series Chipset Family Desktop SATA Contr
/0/100/1f.3                   bus            6 Series/C200 Series Chipset Family SMBus Controller
/0/100/1f.5                   storage        6 Series/C200 Series Chipset Family Desktop SATA Contr
/1           wlx503eaa7c4c9b  network        Wireless interface
WARNING: output may be incomplete or inaccurate, you should run this program as super-user.

3. We can see, the command gives a warning. So when we run lshw command as root user, the output changes. It is now showing information about volumes also.

$ sudo lshw -short|nl
1  H/W path         Device           Class          Description
2	============================================================
3	                                  system         (To be filled by O.E.M.)
4	/0                                bus            DH61WW
5	/0/0                              memory         64KiB BIOS
6	/0/4                              memory         128KiB L1 cache
7	/0/5                              memory         512KiB L2 cache
8	/0/6                              memory         3MiB L3 cache
9	/0/7                              memory         8GiB System Memory
10	/0/7/0                            memory         4GiB DIMM DDR3 Synchronous 1333 MHz (0.8 ns)
11	/0/7/1                            memory         4GiB DIMM DDR3 Synchronous 1333 MHz (0.8 ns)
12	/0/2a                             processor      Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
13	/0/100                            bridge         Xeon E3-1200 v2/3rd Gen Core processor DRAM Controller
14	/0/100/2                          display        Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller
15	/0/100/16                         communication  6 Series/C200 Series Chipset Family MEI Controller #1
16	/0/100/19        enp0s25          network        82579V Gigabit Network Connection
17	/0/100/1a                         bus            6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2
18	/0/100/1a/1      usb1             bus            EHCI Host Controller
19	/0/100/1a/1/1                     bus            Integrated Rate Matching Hub
20	/0/100/1a/1/1/1                   input          USB Optical Mouse
21	/0/100/1a/1/1/3                   input          USB KVM
22	/0/100/1a/1/1/4                   input          Dell KB216 Wired Keyboard
23	/0/100/1b                         multimedia     6 Series/C200 Series Chipset Family High Definition Audio Controller
24	/0/100/1c                         bridge         6 Series/C200 Series Chipset Family PCI Express Root Port 1
25	/0/100/1c/0                       bridge         IT8892E PCIe to PCI Bridge
26	/0/100/1d                         bus            6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1
27	/0/100/1d/1      usb2             bus            EHCI Host Controller
28	/0/100/1d/1/1                     bus            Integrated Rate Matching Hub
29	/0/100/1d/1/1/6                   generic        802.11n NIC
30	/0/100/1f                         bridge         H61 Express Chipset LPC Controller
31	/0/100/1f.2                       storage        6 Series/C200 Series Chipset Family Desktop SATA Controller (IDE mode, ports 0-3)
32	/0/100/1f.3                       bus            6 Series/C200 Series Chipset Family SMBus Controller
33	/0/100/1f.5                       storage        6 Series/C200 Series Chipset Family Desktop SATA Controller (IDE mode, ports 4-5)
34	/0/1             scsi1            storage        
35	/0/1/0.0.0       /dev/sda         disk           500GB WDC WD5000AAKX-0
36	/0/1/0.0.0/1     /dev/sda1        volume         14GiB Linux swap volume
37	/0/1/0.0.0/2     /dev/sda2        volume         74GiB EXT4 volume
38	/0/1/0.0.0/3     /dev/sda3        volume         232GiB EXT4 volume
39	/0/1/0.0.0/4     /dev/sda4        volume         143GiB Extended partition
40	/0/1/0.0.0/4/5   /dev/sda5        volume         143GiB Linux filesystem partition
41	/1               wlx503eaa7c4c9b  network        Wireless interface

In the above example, we have used a linux command nl to filter the results, so that output lines are numbered. We can see there is only one physical disk connected with the system (Line 37). Similarly, we can see there are 8GB RAM in the system, 4GB each in two memory slots (Line 9-11).

4. We can use -businfo option to output the device list showing bus information, detailing SCSI, USB, IDE and PCI addresses.

$ sudo lshw -businfo
Bus info          Device           Class          Description
=============================================================
                                   system         (To be filled by O.E.M.)
                                   bus            DH61WW
                                   memory         64KiB BIOS
                                   memory         128KiB L1 cache
                                   memory         512KiB L2 cache
                                   memory         3MiB L3 cache
                                   memory         8GiB System Memory
                                   memory         4GiB DIMM DDR3 Synchronous 1333 MHz (0.8 ns)
                                   memory         4GiB DIMM DDR3 Synchronous 1333 MHz (0.8 ns)
cpu@0                              processor      Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz
pci@0000:00:00.0                   bridge         Xeon E3-1200 v2/3rd Gen Core processor DRAM Contr
pci@0000:00:02.0                   display        Xeon E3-1200 v2/3rd Gen Core processor Graphics C
pci@0000:00:16.0                   communication  6 Series/C200 Series Chipset Family MEI Controlle
pci@0000:00:19.0  enp0s25          network        82579V Gigabit Network Connection
pci@0000:00:1a.0                   bus            6 Series/C200 Series Chipset Family USB Enhanced 
usb@1             usb1             bus            EHCI Host Controller
usb@1:1                            bus            Integrated Rate Matching Hub
usb@1:1.1                          input          USB Optical Mouse
usb@1:1.3                          input          USB KVM
usb@1:1.4                          input          Dell KB216 Wired Keyboard
pci@0000:00:1b.0                   multimedia     6 Series/C200 Series Chipset Family High Definiti
pci@0000:00:1c.0                   bridge         6 Series/C200 Series Chipset Family PCI Express R
pci@0000:01:00.0                   bridge         IT8892E PCIe to PCI Bridge
pci@0000:00:1d.0                   bus            6 Series/C200 Series Chipset Family USB Enhanced 
usb@2             usb2             bus            EHCI Host Controller
usb@2:1                            bus            Integrated Rate Matching Hub
usb@2:1.6                          generic        802.11n NIC
pci@0000:00:1f.0                   bridge         H61 Express Chipset LPC Controller
pci@0000:00:1f.2                   storage        6 Series/C200 Series Chipset Family Desktop SATA 
pci@0000:00:1f.3                   bus            6 Series/C200 Series Chipset Family SMBus Control
pci@0000:00:1f.5                   storage        6 Series/C200 Series Chipset Family Desktop SATA 
                  scsi1            storage        
scsi@1:0.0.0      /dev/sda         disk           500GB WDC WD5000AAKX-0
scsi@1:0.0.0,1    /dev/sda1        volume         14GiB Linux swap volume
scsi@1:0.0.0,2    /dev/sda2        volume         74GiB EXT4 volume
scsi@1:0.0.0,3    /dev/sda3        volume         232GiB EXT4 volume
scsi@1:0.0.0,4    /dev/sda4        volume         143GiB Extended partition
                  /dev/sda5        volume         143GiB Linux filesystem partition
usb@2:1.6         wlx503eaa7c4c9b  network        Wireless interface
$ 

5. We can use -class option to display particular class of devices. If we want to see only the disk devices and memory devices we use the following command. Here we are using -short option to see a compact output.

$ lshw -short -class memory -class network
WARNING: you should run this program as super-user.
H/W path     Device           Class          Description
========================================================
/0/0                          memory         7814MiB System memory
/0/100/19    enp0s25          network        82579V Gigabit Network Connection
/1           wlx503eaa7c4c9b  network        Wireless interface
WARNING: output may be incomplete or inaccurate, you should run this program as super-user.
$     
Advertisements