The hwinfo command in Linux: complete hardware information

Introduction

In the world of Linux system administration, knowing the installed hardware in depth is essential for tasks such as performance optimization, upgrade planning, and troubleshooting. The hwinfo command presents itself as a comprehensive and detailed tool that gathers information about virtually all components of the system. From the CPU clock speed to RAM timings, through the exact model of the network card and the motherboard firmware version, hwinfo provides data that would be difficult to obtain via several separate commands.

What is hwinfo?

hwinfo is a command-line utility that queries the system via the libhd library and displays exhaustive data about the CPU, memory, storage devices, network cards, graphics card, and many other peripherals. Unlike simpler tools such as lshw or dmidecode, hwinfo offers a level of detail that includes firmware information, drivers, and specific capabilities of each component. Moreover, its output can be formatted as plain text, JSON, or XML, facilitating its integration into monitoring and automation scripts.

Installation

In most modern distributions, hwinfo is available in the official repositories. In Debian and its derivatives like Ubuntu, simply run sudo apt update followed by sudo apt install hwinfo. In Red Hat Enterprise Linux, CentOS, and Fedora, the package is installed with sudo dnf install hwinfo or sudo yum install hwinfo depending on the version. In Arch Linux and its derivatives, the command is obtained with sudo pacman -S hwinfo. After installation, the binary is located in /usr/bin/hwinfo and is ready to use without additional configuration.

Basic Usage

Running hwinfo without arguments produces an extensive output covering all detected devices. To get a quick overview, you can use the summary with the –short argument, which shows only the models and basic states of each component. For example, hwinfo –short lists the CPU, memory, disks, and network interfaces in a few lines. If information for a specific category is required, you can use shortcuts such as –cpu for the central processing unit, –mem for memory, –disk for storage disks, and –net for network cards.

Common Examples

Some of the most frequent uses of hwinfo include:

  • View the model and clock speed of each CPU core: hwinfo –cpu
  • Obtain the capacity, type, and speed of RAM modules: hwinfo –mem
  • List hard drives and SSDs with their size, interface, and serial number: hwinfo –disk
  • Show graphics card information, including chipset and driver version: hwinfo –gfxcard
  • Query the status of network interfaces, such as link speed and manufacturer: hwinfo –net
  • Obtain a full report in JSON format for later processing: hwinfo –json > reporte.json

Output and Filtering

The output of hwinfo can be voluminous, but includes options to filter and format the information. The –filter argument allows showing only certain fields, for example hwinfo –filter cpu.*MHz will display only the CPU speed. Likewise, the –log-level argument controls verbosity, reducing debug messages when not needed. To save the output to a readable file, you can redirect the console to a text file or use the –output archivo.txt option. In monitoring environments, combining hwinfo with tools like grep or awk facilitates extraction of specific data, such as the motherboard serial number: hwinfo –bios | grep Serial Number.

Conclusion

hwinfo has become one of the most complete tools for hardware inventory on Linux systems. Its ability to provide finely granular details, together with the possibility of exporting data in several formats, makes it an indispensable ally for administrators, developers, and enthusiasts who need to know their system thoroughly. Whether for planning an upgrade, diagnosing a failure, or simply documenting the configuration, hwinfo provides the necessary information quickly and reliably.

This post is also available in ESPAÑOL.

Leave a Reply

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

Esta obra está bajo una Licencia Creative Commons Atribución 4.0 Internacional para Francesc Roig francesc@vivaldi.net .