lshw Command in Linux: List Hardware (CPU, Disk, Memory, Network)

lshw reports hardware configuration — CPU, memory, disks, network, and firmware — from DMI, PCI, and kernel interfaces. Run it with sudo for full detail; use -short, -json, or -class to narrow output.

Published

Updated

Read time 7 min read

Reviewed byDeepak Prasad

lshw Command in Linux: List Hardware (CPU, Disk, Memory, Network)
About lshw reports hardware configuration — CPU, memory, disks, network, and firmware — from DMI, PCI, and kernel interfaces. Run it with sudo for full detail; use -short, -json, or -class to narrow output.
Tested on Ubuntu 25.04 (Plucky Puffin); lshw 02.19.git.2021.06.19.996aaad9c7-2.1ubuntu1; kernel 7.0.0-27-generic
Package lshw
Man page lshw(1)
Privilege root / sudo for full hardware access
Distros

Ubuntu, Debian, Fedora, and most Linux distros (lshw package).

CPU-only summary without root: lscpu.

lshw — quick reference

Output formats

Pick a format before dumping the full tree — full lshw without filters is very long.

When to use Command
Full hardware tree (needs root for everything) sudo lshw
Compact hardware path list sudo lshw -short
Bus addresses and device nodes sudo lshw -businfo
HTML report on stdout sudo lshw -html
XML tree sudo lshw -xml
JSON object sudo lshw -json

Filter by class

When to use Command
Disk and volume details sudo lshw -class disk
Network interfaces sudo lshw -class network
Processor information sudo lshw -class processor
Memory modules sudo lshw -class memory
Storage controllers sudo lshw -class storage
Display / GPU sudo lshw -class display

Privacy and diagnostics

When to use Command
Remove serials and IP addresses from output sudo lshw -sanitize
Show numeric PCI/USB IDs sudo lshw -numeric
Suppress progress status lines sudo lshw -quiet
Omit volatile timestamps sudo lshw -notime
Enable a detection backend (pci, cpuid, usb, …) sudo lshw -enable TEST
Disable a backend to compare results sudo lshw -disable TEST
Print program version lshw -version

lshw — command syntax

Usage from lshw on Ubuntu 25.04 (run with no arguments to see format and option list):

text
lshw [-format] [-options ...]
lshw -version

format can be
	-html           output hardware tree as HTML
	-xml            output hardware tree as XML
	-json           output hardware tree as a JSON object
	-short          output hardware paths
	-businfo        output bus information

options can be
	-class CLASS    only show a certain class of hardware
	-C CLASS        same as '-class CLASS'
	-c CLASS        same as '-class CLASS'
	-disable TEST   disable a test (like pci, isapnp, cpuid, etc. )
	-enable TEST    enable a test (like pci, isapnp, cpuid, etc. )
	-quiet          don't display status
	-sanitize       sanitize output (remove sensitive information like serial numbers, etc.)
	-numeric        output numeric IDs (for PCI, USB, etc.)
	-notime         exclude volatile attributes (timestamps) from output

Without root, lshw hides some properties — use sudo for audits and support bundles.


lshw — command examples

Essential Compact hardware overview with -short

Scan the machine quickly — paths, classes, and descriptions on one screen per device.

Run the command:

bash
sudo lshw -short | head -20

Sample output:

text
H/W path            Device      Class       Description
=======================================================
                                system      VirtualBox
/0                              bus         VirtualBox
/0/0                            memory      128KiB BIOS
/0/1                            memory      6GiB System memory
/0/2                            processor   Intel(R) Core(TM) Ultra 5 135U
/0/100/3            enp0s3      network     82540EM Gigabit Ethernet Controller
/0/100/8            enp0s8      network     82540EM Gigabit Ethernet Controller
/0/100/d/0          /dev/sda    disk        26GB VBOX HARDDISK

Use the Class column to pick a filter for deeper -class queries.

Essential Network interfaces with -class network

Document NIC models, drivers, MAC addresses, and link speed for change control.

Run the command:

bash
sudo lshw -class network

Sample output:

text
*-network:0
       description: Ethernet interface
       product: 82540EM Gigabit Ethernet Controller
       vendor: Intel Corporation
       logical name: enp0s3
       serial: 08:00:27:26:59:37
       size: 1Gbit/s
       configuration: driver=e1000 ip=10.0.2.15 link=yes speed=1Gbit/s
  *-network:1
       description: Ethernet interface
       logical name: enp0s8
       serial: 08:00:27:ec:19:c8
       configuration: driver=e1000 ip=192.168.0.4 link=yes speed=1Gbit/s

Match logical name with ip link when troubleshooting connectivity.

Essential Disks and volumes with -class disk

See attached disks, sizes, partition layout, and device nodes.

Run the command:

bash
sudo lshw -class disk

Sample output:

text
*-disk:0
       description: ATA Disk
       product: VBOX HARDDISK
       logical name: /dev/sda
       size: 25GiB (26GB)
       capabilities: gpt-1.00 partitioned partitioned:gpt
     *-volume:0
          logical name: /dev/sda2
          size: 2GiB
          description: EXT4 volume

Pair with df or lsblk for mount points and free space.

Common Bus addresses with -businfo

Map PCI/USB paths to kernel device names — useful before driver work.

Run the command:

bash
sudo lshw -businfo | head -15

Sample output:

text
Bus info          Device      Class       Description
=====================================================
pci@0000:00:03.0  enp0s3      network     82540EM Gigabit Ethernet Controller
pci@0000:00:08.0  enp0s8      network     82540EM Gigabit Ethernet Controller
scsi@2:0.0.0      /dev/sda    disk        26GB VBOX HARDDISK

The Bus info column ties hardware to udev and sysfs paths.

Common CPU details with -class processor

Vendor, product string, and capability flags from hardware discovery.

Run the command:

bash
sudo lshw -class processor

Sample output:

text
*-cpu
       product: Intel(R) Core(TM) Ultra 5 135U
       vendor: Intel Corp.
       width: 64 bits
       capabilities: fpu vme de pse tsc msr pae mce cx8 apic ...

For topology (cores, NUMA), also run lscpu.

Common Shareable output with -sanitize

Strip serial numbers, UUIDs, and IP addresses before posting logs publicly.

Run the command:

bash
sudo lshw -sanitize -short | head -12

Sample output:

text
H/W path            Device      Class       Description
=======================================================
                                system      VirtualBox
/0/1                            memory      6GiB System memory
/0/2                            processor   Intel(R) Core(TM) Ultra 5 135U
/0/100/3            enp0s3      network     82540EM Gigabit Ethernet Controller

Sensitive fields show [REMOVED] in full-tree mode — safe for tickets and forums.

Advanced JSON export for automation

Feed configuration management or inventory scripts.

Run the command:

bash
sudo lshw -json -class network | head -20

Sample output:

text
[
  {
    "id" : "network:0",
    "class" : "network",
    "claimed" : true,
    "handle" : "PCI:0000:00:03.0",
    "description" : "Ethernet interface",
    "product" : "82540EM Gigabit Ethernet Controller",
    "logicalname" : "enp0s3",
    "serial" : "08:00:27:26:59:37",
    "configuration" : {
      "driver" : "e1000",
      "ip" : "10.0.2.15",
      "link" : "yes"
    }
  }
]
Advanced Memory summary with -class memory

Report RAM size and BIOS memory regions — not a substitute for free -h runtime usage.

Run the command:

bash
sudo lshw -class memory

Sample output:

text
*-firmware
       description: BIOS
       vendor: innotek GmbH
       version: VirtualBox
       size: 128KiB
  *-memory
       description: System memory
       size: 6GiB

Use free -h for available RAM right now; pair with dmidecode -t memory for DIMM slot layout from firmware.


lshw — when to use / when not

Use lshw when Use something else when
  • You need a hardware inventory for support tickets or CMDB records
  • You want class-filtered reports (disk, network, processor, …)
  • You export HTML, XML, or JSON for audits
  • You sanitize output before sharing logs externally
  • You only need CPU topology → lscpu
  • You need raw DMI/SMBIOS strings → dmidecode
  • You only need PCI devices → lspci
  • You need block layout and mounts → lsblk
  • You measure live performance → iostat or top

lshw vs lscpu vs dmidecode

lshw lscpu dmidecode
Scope Full hardware tree CPU/cache/NUMA DMI tables
Root needed For full detail No For full detail
Output formats text, HTML, XML, JSON text, JSON text
Best for Asset inventory Scheduler/affinity BIOS/vendor strings

Inventory and capacity tools often used together.

Command One line
lshw Hardware lister (this page)
lsblk Block device tree
free Current memory usage

Browse the full index in our Linux commands reference.


lshw — interview corner

What is lshw used for?

lshw (hardware lister) discovers and prints machine hardware — buses, CPU, memory, disks, network, USB, and more. It combines DMI, PCI, and kernel data into one tree. Run sudo lshw when you need full properties; sudo lshw -short for a quick map.

A strong answer is:

"lshw inventories hardware — CPU, RAM, disks, NICs — from DMI and PCI. I use -short for overview and -class network or disk for focused reports."

Why run lshw with sudo?

Without root, lshw omits or masks some properties (disk serials, full memory SPD, certain PCI config). sudo lshw reads everything the kernel exposes — standard for support bundles and asset audits.

A strong answer is:

"Root unlocks full detail — unprivileged lshw is partial. I sudo for complete inventory before RMA or documentation."

How do you list only network hardware?

Use -class network (or -C network):

bash
sudo lshw -class network

Other common classes: disk, processor, memory, storage, display. Run sudo lshw -short first to see class names on your system.

A strong answer is:

"-class network filters the tree — same for disk or processor. -short helps me find the right class name."

When use lshw -sanitize?

Before attaching hardware dumps to public tickets, forums, or chat, run:

bash
sudo lshw -sanitize

It removes serials, UUIDs, and IP addresses while keeping model and layout information useful for debugging.

A strong answer is:

"-sanitize redacts sensitive fields — I use it whenever I share lshw output outside the org."

lshw vs lscpu for CPU information?

lscpu reads kernel CPU topology — cores, threads, NUMA, caches — without root. lshw reports hardware product strings and capabilities from discovery probes. Use lscpu for tuning; use lshw for asset records alongside disks and NICs.

A strong answer is:

"lscpu for topology and scripting; lshw for full hardware context including CPU product name in an inventory pass."


Troubleshooting

Symptom Likely cause Fix
Partial output without serials Not run as root Use sudo lshw
lshw: command not found Package missing sudo apt install lshw
Empty -class section Wrong class name Run sudo lshw -short to find class
Very slow run Large -json full tree Filter with -class or use -short
VM shows generic devices Virtual hardware Expected — compare with hypervisor console
-sanitize still shows sensitive text Custom fields outside redaction list Redact manually before sharing
lshw -version prints blank Known quirk on Ubuntu 02.19 build Check dpkg-query -W lshw for package version — see dpkg command

Rohan Timalsina

is a technical writer and Linux enthusiast who writes practical guides on Linux commands and system administration. He focuses on simplifying complex topics through clear explanations.