How to Use the lshw Command to View Your Hardware Configuration in Linux

When you are troubleshooting a failing Linux server or preparing to install complex proprietary drivers (like Nvidia GPU software), you need to know exactly what hardware is physically installed inside the machine. You cannot just open the server case if it is located in a remote data center. To generate a massive, highly detailed inventory of every single hardware component connected to your system—from the motherboard down to individual USB ports—you must use the lshw (list hardware) command.

How to Run lshw

Because the lshw command dives deep into the system’s BIOS/UEFI and queries raw hardware buses, it requires root privileges to provide a complete picture. If you run it as a standard user, the output will be missing crucial details like serial numbers and exact memory speeds.

sudo lshw

When you press Enter, lshw will output a massive wall of text. It organizes the data hierarchically, starting with the core system board, then the CPU, then branching out to the memory banks, PCI Express slots, network interfaces, and disk drives.

Because the output is usually hundreds of lines long, it is highly recommended to pipe the output into a pager like less so you can scroll through it comfortably:

sudo lshw | less

Filtering for Specific Hardware

If you only care about one specific component, scrolling through the entire system tree is inefficient. The lshw command provides a -class flag that allows you to instantly filter the massive output down to exactly what you need to see.

  • Find RAM Details: To see exactly how many sticks of RAM are installed, their speed, and their physical slots, use the memory class.
    sudo lshw -class memory
  • Find Network Adapters: To find the exact manufacturer, driver version, and MAC address of your Ethernet or Wi-Fi cards, use the network class.
    sudo lshw -class network
  • Find Storage Drives: To see the brand, size, and logical name (like /dev/sda) of every hard drive and SSD connected to the motherboard, use the disk class.
    sudo lshw -class disk

Generating a Shareable HTML Report

If you need to send your system’s hardware configuration to an IT support technician, copying and pasting hundreds of lines of terminal text is messy. The lshw tool has a brilliant built-in feature that can format the hardware tree into a clean, readable web page.

sudo lshw -html > hardware_report.html

This command securely dumps all the hardware data into an HTML file on your drive. You can then open hardware_report.html in any web browser to view a beautifully formatted table of your system specifications, which you can easily email to support teams.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.