Quick take: sudo lshw -short gives a compact one-line-per-device hardware summary. Use -class disk, -class network, or -class memory to filter by device type. Generate an HTML report with sudo lshw -html > report.html.
Introduction
lshw (List Hardware) is a comprehensive hardware information tool that reads system hardware details from multiple sources: /proc, /sys, DMI/BIOS tables, and direct hardware probing. It shows model names, firmware versions, bus speeds, driver names, and logical device names — all in one command.
It is the go-to tool when you need to document server specifications for a client, verify hardware before a firmware upgrade, or diagnose driver binding issues for a newly added device.
Install lshw
# Ubuntu / Debian
sudo apt install lshw
# RHEL / CentOS / Rocky
sudo dnf install lshw
# Verify
lshw -versionSyntax
sudo lshw [OPTIONS]Root privileges are required for complete hardware data. Without sudo, many device entries show as "UNCLAIMED" or display incomplete information.
Common Options
| Option | Description |
|---|---|
| -short | Compact tabular view — one line per device |
| -html | Output as an HTML page |
| -json | Output as JSON (pipe to jq for processing) |
| -xml | Output as XML |
| -class CLASS | Filter by device class (disk, network, memory, processor, etc.) |
| -C CLASS | Short form of -class |
| -businfo | Show bus information (PCI bus IDs, USB ports) |
| -sanitize | Remove sensitive data (serial numbers) before sharing output |
| -quiet | Suppress progress messages |
Practical Examples
# Quick summary — best starting point
sudo lshw -short
# Filter to memory modules only
sudo lshw -class memory -short
# Filter to disks
sudo lshw -class disk -short
# Filter to network interfaces
sudo lshw -class network -short
# Filter to CPU
sudo lshw -class processor
# Show PCI bus info for all devices
sudo lshw -businfo
# JSON output — pipe to jq
sudo lshw -json | jq '.children[] | select(.class == "storage")'
# Safe output for sharing (removes serial numbers)
sudo lshw -short -sanitizeSample lshw -short output:
H/W path Device Class Description
====================================================
system PowerEdge R640
/0 bus 0CXJM3
/0/0 memory 64GiB System Memory
/0/0/0 memory 32GiB DIMM DDR4 Synchronous 2666 MHz
/0/1 processor Intel Xeon Silver 4210R
/0/100/1f.2 /dev/sda disk 240GB SATA SSD
/0/100/1f.2/0 volume 223GiB EXT4 volume
/1 eno1 network Ethernet interface 10GbEGenerate an HTML Report
For client documentation or asset management, lshw can generate a formatted HTML page:
# Generate and save HTML report
sudo lshw -html > /tmp/hardware_report.html
# Sanitize (remove serial numbers) then generate
sudo lshw -html -sanitize > /tmp/hardware_report_safe.html
# View in browser (on a desktop system)
xdg-open /tmp/hardware_report.html
# Transfer to your laptop for viewing
scp server:/tmp/hardware_report.html ~/Downloads/The HTML report is well-formatted and includes color-coded device classes — useful for sending to procurement teams or storing in a server inventory system.
Related Hardware Commands
lshw covers the full hardware picture, but these focused tools complement it:
lscpu— CPU details, cores, NUMA topology, flagslsblk— Block device tree (disks, partitions, LVM volumes)lspci— PCI bus devices (GPUs, network cards, RAID controllers)lsusb— USB devices and their bus addressesdmidecode— Raw BIOS/UEFI DMI table data (memory speed, firmware version)inxi -Fxz— Another comprehensive hardware overview tool
# CPU details
lscpu
# Disk and partition tree
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
# PCI devices
lspci -v
# Memory DIMM details from DMI
sudo dmidecode -t memory | grep -E "Size|Speed|Manufacturer|Part"Final Thoughts
lshw is the most complete single-command hardware inventory tool available on Linux. Start with sudo lshw -short for a quick overview and add -class filtering to drill into specific subsystems. For documentation and client reports, the HTML output format is professional enough to send directly without formatting.
FAQ: lshw Command in Linux
How do I install lshw on Ubuntu?+
Run sudo apt install lshw. On RHEL/CentOS, use sudo dnf install lshw. After install, run sudo lshw -short for a quick hardware overview.
Why does lshw need to be run with sudo?+
Without root privileges, lshw cannot read all hardware registers and will show incomplete or unknown data for many devices. Always run sudo lshw for complete results.
How do I get a summary hardware list instead of full details?+
Use sudo lshw -short for a compact tabular view with one line per device, showing bus path, device name, class, and description. This is the most readable format for a quick inventory.
How do I generate an HTML hardware report with lshw?+
Run sudo lshw -html > hardware_report.html. This creates a formatted HTML page you can open in a browser and share with clients or colleagues as a server inventory document.
How do I filter lshw to show only network cards?+
Use sudo lshw -class network. Other useful classes include memory, disk, display, processor, and storage. Combine with -short for concise output: sudo lshw -class disk -short.
Need help with Linux servers or infrastructure?
Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.
Hire Me for Support