lshw Command in Linux: How to List Detailed Hardware Information

lshw Command in Linux: How to List Detailed Hardware Information

Learn how to use the lshw command in Linux to view complete hardware details. Includes installation steps, examples, and tips for system administrators.

When it comes to system administration or troubleshooting in Linux, understanding your hardware is just as important as knowing your software stack. The lshw (List Hardware) command is a powerful and detailed tool that provides comprehensive information about the hardware configuration of your Linux system.

Whether you are an IT professional, system administrator, or enthusiast trying to understand the hardware layout of your machine, lshw can give you a complete overview from CPU details to memory configuration and network interfaces.

What is lshw?

The lshw command stands for “List Hardware” It extracts detailed information about your system’s hardware components by reading from various system files under /proc and /sys.

Unlike simple commands like lscpu or lsblk that focus on specific components, lshw provides a complete hierarchical view of the hardware, including:

  • CPU architecture
  • Memory and cache details
  • Storage devices
  • Motherboard and BIOS information
  • Network interfaces
  • USB and PCI devices

How to Install lshw

In most Linux distributions, lshw is not pre-installed but can be easily added using your package manager.

For Debian/Ubuntu-based systems:

sudo apt update
sudo apt install lshw -y

For Red Hat/CentOS/Fedora-based systems:

sudo yum install lshw -y

or

sudo dnf install lshw -y

Once installed, you can verify it using:

lshw --version

Basic Usage

To display a complete hardware summary:

sudo lshw

⚠️ Note: Running lshw with sudo provides full details. Without root privileges, some information might be hidden due to restricted access.

Examples and Common Options

1. Display a Short Summary

If you want a concise overview:

sudo lshw -short

This displays a compact, table-like format with columns for class, description, and hardware path.

Output:

H/W path          Device      Class       Description
=====================================================
                              system      VirtualBox
/0                            bus         VirtualBox
/0/0                          memory      128KiB BIOS
/0/1                          memory      31GiB System memory
/0/2                          processor   Intel(R) Xeon(R) CPU E5-1630 v3 @ 3.70GHz
/0/100                        bridge      440FX - 82441FX PMC [Natoma]
/0/100/1                      bridge      82371SB PIIX3 ISA [Natoma/Triton II]
/0/100/1/0                    input       PnP device PNP0303
/0/100/1/1                    input       PnP device PNP0f03
/0/100/1.1        scsi1       storage     82371AB/EB/MB PIIX4 IDE
/0/100/1.1/0.0.0  /dev/cdrom  disk        CD-ROM
/0/100/2          /dev/fb0    display     SVGA II Adapter
/0/100/3          enp0s3      network     82540EM Gigabit Ethernet Controller
/0/100/4          input7      input       VirtualBox mouse integration
/0/100/5          card0       multimedia  82801AA AC'97 Audio Controller
/0/100/6                      bus         KeyLargo/Intrepid USB
/0/100/6/1        usb1        bus         OHCI PCI host controller
/0/100/6/1/1      input6      input       VirtualBox USB Tablet
/0/100/7                      bridge      82371AB/EB/MB PIIX4 ACPI
/0/100/d          scsi2       storage     82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode]
/0/100/d/0.0.0    /dev/sda    disk        644GB VBOX HARDDISK
/0/100/d/0.0.0/1  /dev/sda1   volume      1023KiB BIOS Boot partition
/0/100/d/0.0.0/2  /dev/sda2   volume      800MiB EXT4 volume
/0/100/d/0.0.0/3  /dev/sda3   volume      4095MiB Linux swap volume
/0/100/d/0.0.0/4  /dev/sda4   volume      595GiB EXT4 volume
/1                input0      input       Power Button
/2                input1      input       Sleep Button
/3                input2      input       AT Translated Set 2 keyboard
/4                input4      input       Video Bus
/5                input5      input       ImExPS/2 Generic Explorer Mouse

2. List Hardware by Class

You can filter information for specific hardware categories using the -C option:

sudo lshw -C network
sudo lshw -C display
sudo lshw -C disk

This helps administrators quickly inspect network cards, graphics adapters, or storage devices.

Output:

root@gowripc:/home/gowri# sudo lshw -C network
  *-network
       description: Ethernet interface
       product: 82540EM Gigabit Ethernet Controller
       vendor: Intel Corporation
       physical id: 3
       bus info: pci@0000:00:03.0
       logical name: enp0s3
       version: 02
       serial: 08:00:27:c6:21:71
       size: 1Gbit/s
       capacity: 1Gbit/s
       width: 32 bits
       clock: 66MHz
       capabilities: pm pcix bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=e1000 driverversion=5.15.0-113-generic duplex=full ip=192.168.56.10 latency=64 link=yes mingnt=255 multicast=yes port=twisted pair speed=1Gbit/s
       resources: irq:19 memory:f0200000-f021ffff ioport:d020(size=8)

root@gowripc:/home/gowri# sudo lshw -C display
  *-display
       description: VGA compatible controller
       product: SVGA II Adapter
       vendor: VMware
       physical id: 2
       bus info: pci@0000:00:02.0
       logical name: /dev/fb0
       version: 00
       width: 32 bits
       clock: 33MHz
       capabilities: vga_controller bus_master rom fb
       configuration: depth=32 driver=vmwgfx latency=64 resolution=2048,2048
       resources: irq:18 ioport:d010(size=16) memory:e0000000-e0ffffff memory:f0000000-f01fffff memory:c0000-dffff

root@gowripc:/home/gowri# sudo lshw -C disk
  *-cdrom
       description: DVD reader
       product: CD-ROM
       vendor: VBOX
       physical id: 0.0.0
       bus info: scsi@1:0.0.0
       logical name: /dev/cdrom
       logical name: /dev/sr0
       version: 1.0
       capabilities: removable audio dvd
       configuration: ansiversion=5 status=nodisc
  *-disk
       description: ATA Disk
       product: VBOX HARDDISK
       vendor: VirtualBox
       physical id: 0.0.0
       bus info: scsi@2:0.0.0
       logical name: /dev/sda
       version: 1.0
       serial: VB3b026287-796961ff
       size: 600GiB (644GB)
       capabilities: gpt-1.00 partitioned partitioned:gpt
       configuration: ansiversion=5 guid=71dd9291-607c-46ca-bca0-8533d95ff63a logicalsectorsize=512 sectorsize=512

3. Generate an HTML Report

You can export the hardware summary in HTML format for documentation or sharing:

sudo lshw -html > hardware-report.html

This is especially useful for audit reports or inventory management.

4. Generate an XML or JSON Report

For automated systems or integration with other tools:

sudo lshw -xml > hardware.xml
sudo lshw -json > hardware.json

These structured outputs make it easy to parse hardware data programmatically.

5. Display Memory Information

To list all memory devices and configurations:

sudo lshw -C memory

This provides insight into total memory size, slot usage, and module specifications — useful when upgrading or troubleshooting RAM.

Why Use lshw?

  • Detailed Hardware Insights: Provides low-level information unavailable through most other utilities.
  • System Inventory Management: Ideal for documenting hardware specifications.
  • Troubleshooting Support: Useful for identifying device models and drivers.
  • Automation-Friendly Output: Supports XML, JSON, and HTML exports for integration with monitoring tools.

Alternatives to lshw

While lshw is comprehensive, you can combine it with other Linux utilities for specific insights:

CommandPurpose
lscpuDisplays CPU information
lsblkLists block devices and storage layout
lspciLists PCI devices
lsusbDisplays connected USB devices
dmidecodeProvides BIOS and hardware-level data

Conclusion

The lshw command is one of the most valuable tools for anyone managing Linux systems. From inventory documentation to performance troubleshooting, it delivers a full, structured view of your hardware environment.

By understanding and effectively using lshw, you can gain deeper insights into your Linux systems and ensure efficient system maintenance and optimization.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *