Mastering lshw, dmidecode, and hwinfo: A Deep Dive into Linux Hardware

Linux tutorial - IT technology blog
Linux tutorial - IT technology blog

Check server configuration in just 5 minutes

Imagine you’ve just received an old Dell PowerEdge server from the warehouse without any documentation. You’re wondering how many RAM sticks are installed, their bus speed, or whether the storage is an enterprise SSD or a standard HDD. Instead of shutting it down and struggling to remove the chassis cover, you can use these 3 “handy” commands to get all the component details instantly.

Before starting, install this toolkit if your machine doesn’t have it yet. Minimal distributions often don’t come with these pre-installed:

# On Ubuntu/Debian
sudo apt update && sudo apt install lshw dmidecode hwinfo -y

# On CentOS/RHEL/AlmaLinux
sudo yum install lshw dmidecode hwinfo -y

The fastest way to get an overview is by using the summary command:

sudo lshw -short

This command scans through the entire CPU, RAM, and even PCI expansion cards. It’s extremely useful when you need to quickly report the machine’s configuration to your boss or a client.

Details on the top 3 hardware inspection tools

1. lshw – List hardware in a tree structure

lshw (List Hardware) is the most comprehensive tool for extracting detailed reports. It gathers data from files in /proc, DMI tables, and PCI/USB buses on the motherboard.

A tip I often use is exporting the information to an HTML file. This makes the report look much more professional than a screenshot of a plain terminal:

sudo lshw -html > server-config-01.html

If you only want to inspect a specific component, such as the hard drive, use the -class parameter:

sudo lshw -class disk -class storage

You will immediately see the hard drive model (like Samsung 870 EVO or Intel NVMe), actual capacity, and the connection interface being used.

2. dmidecode – In-depth BIOS and RAM specifications

Unlike lshw, dmidecode focuses on reading data from the DMI (Desktop Management Interface) table. This is where “critical” information like Serial Numbers, BIOS versions, and details of each RAM slot are stored.

In practice, when managing a database server cluster with 128GB of RAM, I use dmidecode to identify exactly which slots are empty without opening the machine. Just run the command:

sudo dmidecode -t memory

The results will tell you: how many slots the machine has in total, whether the current RAM is DDR4 or DDR5, and speeds of 3200MT/s or 4800MT/s. This information helps you buy the correct type of RAM for upgrades, avoiding bus conflicts that cause system hangs.

To retrieve the Serial Number for checking the warranty on Dell or HP websites, use the command:

sudo dmidecode -s system-serial-number

3. hwinfo – Peripheral device detection tool

hwinfo was originally developed for OpenSUSE but is now popular across all Linux operating systems. Its biggest advantage is the ability to probe hardware very deeply, especially peripheral devices and drivers.

Want an extremely concise summary? Type:

hwinfo --short

When a network card has issues, I often use the following command to check the driver (kernel module) controlling it:

hwinfo --network

Data from hwinfo clearly displays the Link status (up/down) and the maximum supported speed (1Gbps or 10Gbps). This helps SysAdmins quickly troubleshoot frequent network drops caused by driver errors or faulty ports.

Smart data filtering tips

Reading through thousands of lines of terminal output is a nightmare. Instead, combine it with grep to filter exactly for the information you need.

For example, to find out how many physical cores the CPU has and its exact model name:

sudo lshw -class processor | grep -E "product|vendor|width"

If you suspect a hard drive is running unusually slow due to firmware issues, you can export a detailed log for analysis:

hwinfo --disk --log=check_disk.log

Real-world experience for IT pros

After years of system administration, I’ve derived 3 golden rules when inspecting hardware:

  • Always use Root privileges: Without sudo, the returned results will be empty or missing critical information from the DMI table and PCI bus.
  • Combine multiple tools: No single command is perfect. On virtual machines (VMs) or custom-built servers, dmidecode might not read the Serial Number; in those cases, lshw is the best backup option.
  • Save configurations periodically: Every time you finish setting up a new server, run lshw -html and save it. When components fail after a few years, you’ll know exactly which model to buy for replacement without having to guess.

Mastering these commands makes you more confident when troubleshooting. Instead of guessing, you’ll always have precise technical data to make decisions about upgrades or repairs.

Share: