LinuxCommandLibrary

lshw

List hardware information

TLDR

Launch the X11 GUI (if available)

$ sudo lshw -X
copy

List all hardware in tabular format
$ sudo lshw -short
copy

List multiple class of hardware (all disks and storage controllers) in tabular format
$ sudo lshw [[-c|-class]] disk [[-c|-class]] storage -short
copy

Save all network interfaces to an HTML/XML/JSON file
$ sudo lshw [[-c|-class]] network -[html|xml|json] > interfaces[.html|.xml|.json]
copy

List network interfaces without revealing sensitive information (IP addresses, serial numbers, etc.)
$ sudo lshw [[-c|-class]] network -sanitize
copy

List a particular class of hardware
$ sudo lshw [[-c|-class]] [system|bridge|memory|processor|address|storage|disk|tape|bus|network|display|input|printer|multimedia|communication|power|volume|generic]
copy

SYNOPSIS

lshw [options]

PARAMETERS

-short, -B
    Produce a shorter, more concise output, summarizing main components and their bus information.

-businfo, -b
    Show bus information in a structured tree format, useful for identifying devices by their bus addresses (e.g., PCI or USB).

-class CLASS, -C CLASS
    Only show devices belonging to the specified hardware CLASS (e.g., 'network', 'display', 'storage', 'cpu').

-disable CLASS, -D CLASS
    Disable scanning for certain hardware CLASSes to speed up execution or avoid issues with specific devices.

-enable CLASS, -E CLASS
    Enable scanning for a certain hardware CLASS. Useful if a class is disabled by default or to override a previous -disable option.

-numeric, -N
    Display numeric IDs (e.g., PCI vendor/device IDs) instead of textual descriptions, useful for database lookups.

-json
    Output the hardware information in JSON format, suitable for programmatic parsing and web applications.

-xml
    Output the hardware information in XML format, commonly used for data exchange and structured documentation.

-html
    Output the hardware information in HTML format, making it easy to view in a web browser for detailed reports.

-quiet, -Q
    Suppress status messages during execution, only showing the final output.

-sanitize, -S
    Sanitize output by hiding sensitive information like serial numbers or UUIDs, useful for sharing system configurations publicly.

-version, -V
    Display the version of the lshw utility and exit.

DESCRIPTION

lshw (list hardware) is a small but powerful command-line utility used to extract and display comprehensive information about a system's hardware configuration. It can report on a wide range of hardware components, including exact memory configuration, firmware version, mainboard details, CPU version and speed, cache setup, bus speeds, network adapters, storage devices, and more.

The tool gathers its information from various sources like the /proc and sysfs filesystems, DMI (Desktop Management Interface) tables, PCI configuration space, and USB descriptors. Its ability to output in multiple formats such as plain text, XML, HTML, and JSON makes it highly versatile for system auditing, inventory management, troubleshooting, and scripting. To obtain the most complete and accurate hardware data, especially from DMI tables, lshw typically requires root privileges.

CAVEATS

For lshw to gather complete and accurate hardware information, especially details from DMI tables (like serial numbers, manufacturer data, and motherboard specifics), it often requires root privileges. Running it as a regular user might result in incomplete output. Additionally, the accuracy and depth of the reported information can depend on the Linux kernel's support for specific hardware components and the availability of appropriate device drivers.

OUTPUT FORMATS

One of lshw's most significant strengths is its versatility in output formats. Beyond the default human-readable plain text, it can generate XML, HTML, and JSON outputs. This makes it incredibly flexible for integration into scripts, automation tools, web-based inventory systems, or simply for generating presentable reports that can be easily shared or archived.

HARDWARE CLASSES

lshw categorizes hardware into logical 'classes' (e.g., 'system', 'memory', 'cpu', 'network', 'disk', 'display'). This classification system allows users to filter the output and focus on specific types of hardware using the -class or -C option, providing a more manageable view of complex systems.

HISTORY

lshw was originally developed by Alexandre Oliva, with its first release dating back to 2002. From its inception, the goal was to provide a unified and structured way to report on diverse hardware components. Its comprehensive output capabilities and support for multiple output formats quickly led to its widespread adoption across various Linux distributions, making it a standard and indispensable tool for system administrators and hardware diagnostics.

SEE ALSO

lspci(8), lsusb(8), dmidecode(8), hwinfo(8), proc(5), sysfs(5)

Copied to clipboard