How to Check Hardware Specifications in Linux Using lshw

If you are managing a headless Linux server over SSH, or if you have recently purchased a second-hand computer and installed Ubuntu, you need to know exactly what hardware is under the hood. Unlike Windows or macOS, which provide graphical “About This Mac” or “Device Manager” windows, Linux often requires you to query your components directly from the command line.

While there are dozens of single-purpose commands (like lscpu for the processor or free -m for RAM), the most comprehensive tool available is the “List Hardware” utility. By learning how to check hardware specifications in Linux using lshw, you can generate a complete, highly detailed report of every single component physically connected to your motherboard.

Installing the lshw Utility

The lshw utility is pre-installed on many popular distributions, including Ubuntu and Debian. However, if you are using a minimal server installation, you may need to install it manually.

Open your terminal and run the following command to ensure the tool is available:

sudo apt update && sudo apt install lshw

(If you are using Fedora or CentOS, replace apt with dnf or yum).

Generating a Complete Hardware Report

Because querying low-level hardware components requires administrative privileges, you must always run lshw as the root user. If you run it as a standard user, the output will be incomplete or missing critical details like serial numbers.

To generate the master report, type:

sudo lshw

The terminal will instantly populate with thousands of lines of highly technical information. The output is structured in a logical “tree” format, starting from the motherboard (the core) and branching out to the CPU, memory banks, PCI buses, network cards, and storage drives.

Filtering the Output with the -short Flag

The standard output of sudo lshw is usually too overwhelming for a quick check. If you simply want a broad overview of the system—identifying the processor model, the total amount of RAM, and the size of the hard drive—you should use the -short flag.

sudo lshw -short

This command strips away the verbose technical data and presents a clean, readable table. The table includes columns for the hardware Class (e.g., memory, processor, disk), the Device name, and a brief Description.

Targeting Specific Hardware Components

If you only care about one specific piece of hardware—for example, you are trying to find the MAC address of your Wi-Fi card or verify the clock speed of your CPU—you can force lshw to filter its output using the -class flag.

Here are the most useful class filters:

  • Check RAM: sudo lshw -class memory (This will show you exactly how many RAM slots are populated and the speed of each stick).
  • Check CPU: sudo lshw -class processor
  • Check Storage: sudo lshw -class disk
  • Check Network Cards: sudo lshw -class network (Highly useful for distinguishing between Ethernet and Wi-Fi interfaces).

Exporting the Hardware Report

If you need to send your hardware specifications to IT support, or if you want to keep a record of your server’s build, reading the output in the terminal is not practical. Fortunately, lshw can automatically format its output into an HTML file or a structured JSON document.

To generate a beautiful, easily readable HTML webpage containing all your hardware data, use the -html flag and redirect the output to a file:

sudo lshw -html > hardware_report.html

You can then open hardware_report.html in any web browser to view a neatly organised table of your entire system.

Leave a Reply

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

Get the best tech tips delivered straight to your inbox.

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

Receive our best articles and tips delivered straight to your inbox.