LinuxCommandLibrary

lshw

List hardware information

TLDR

Launch the GUI

$ sudo lshw -X
copy

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

List all disks and storage controllers in tabular format
$ sudo lshw -class disk -class storage -short
copy

Save all network interfaces to an HTML file
$ sudo lshw -class network -html > [interfaces.html]
copy

SYNOPSIS

lshw [ options ]

PARAMETERS

-help
    Displays a help message with available options.

-version
    Shows the version of lshw.

-format format
    Specifies the output format. Supported formats include html, xml, json, and short (default is plain text).

-class class
    Limits the output to a specific hardware class (e.g., network, disk, memory). See output of the `lshw` command for all possible classes

-C class
    Same as -class class.

-businfo
    Displays bus information (e.g., PCI slot, USB port) for each device.

-numeric
    Displays numeric IDs instead of human-readable descriptions.

-quiet
    Reduces the amount of output. Useful for automated scripting.

-sanitize
    Masks potentially sensitive information (e.g., serial numbers) in the output.

-enable capability
    Enables a specific capability during hardware detection.
Examples are: 'pci', 'dmi', 'usb', 'memory', 'cpu', 'scsi', 'ide', 'network', 'bios', 'floppy', 'cdrom', 'partition', 'volume', 'power', 'bridge', 'system', 'mainboard', 'display', 'multimedia', 'printer', 'camera', 'input', 'storage', 'bus', 'generic'

-disable capability
    Disables a specific capability during hardware detection.
Examples are: 'pci', 'dmi', 'usb', 'memory', 'cpu', 'scsi', 'ide', 'network', 'bios', 'floppy', 'cdrom', 'partition', 'volume', 'power', 'bridge', 'system', 'mainboard', 'display', 'multimedia', 'printer', 'camera', 'input', 'storage', 'bus', 'generic'

-notty
    Disables the use of terminal control codes for formatting.

-dump
    Dumps raw hardware information, which may be useful for debugging.

-html
    Equivalent to -format html.

-xml
    Equivalent to -format xml.

-json
    Equivalent to -format json.

DESCRIPTION

lshw (List Hardware) is a command-line utility that gathers detailed information about the hardware components of a Linux system. It scans the system's hardware and reports on devices such as the CPU, memory, disk drives, network interfaces, graphics cards, and various bus controllers. lshw can generate output in various formats, including plain text, XML, and HTML, making it suitable for both human readability and automated processing. It doesn't directly interact with the hardware to modify its configuration, it only reads the data. The information presented by lshw is useful for system administrators, developers, and end-users who need a comprehensive overview of the system's hardware configuration. It is particularly useful when troubleshooting hardware problems, verifying driver compatibility, or documenting system specifications. The utility aims to provide detailed output without requiring extensive knowledge of the underlying hardware.

CAVEATS

The accuracy of the information provided by lshw depends on the completeness and accuracy of the system's hardware description. Certain virtualized environments or systems with poorly configured hardware may not provide accurate information. Root privileges may be needed to obtain information about all hardware components.

EXIT STATUS

lshw returns 0 on success and a non-zero value on failure. A failure usually indicates problems accessing hardware information, such as insufficient permissions or errors during hardware probing.

EXAMPLES

To list all hardware information in HTML format: lshw -html > hardware.html
To list only network devices: lshw -class network
To display CPU information with bus details: lshw -class processor -businfo

HISTORY

The lshw utility was developed to provide a standardized way to access hardware information across different Linux distributions. It has been actively maintained and updated to support new hardware devices and features. The goal was to create a tool that is both comprehensive and easy to use, abstracting away the complexities of accessing hardware information directly from the kernel.

SEE ALSO

lspci(8), lsusb(8), dmidecode(8), hwinfo(8)

Copied to clipboard