Open In App

lshw command in Linux with Examples

Improve
Improve
Like Article
Like
Save
Share
Report

lshw(list hardware) is a small Linux/Unix tool which is used to generate the detailed information of the system’s hardware configuration from various files in the /proc directory. lshw can also report exact memory configuration, firmware version, mainboard configuration, CPU version and speed, cache memory configuration, bus speed, etc on DMI-capable x86 or IA-64(Itanium family of 64 microprocessors) system and some PowerPC machine. This command needs root permission to show full information else partial information will be displayed.

Syntax:

lshw [-format] [-options ...]

Where format can be:

  • -html: Output hardware tree as HTML.
  • -xml: Output hardware tree as XML.
  • -short: Output hardware paths.
  • -businfo: Output bus information.

Example 1: To display full hardware information.

Input:

Output:

Example 2: Lists hardware in a compact format.

Input:

Output:

Options:

  • -class CLASS: This option is used when we only want lshw command to show a certain class of hardware.

    Example 1: To lists all disks and storage controllers in the system.

    Example 2: To lists all network interfaces in HTML file say geeksforgeeks.html.

    Input:

    A file namely geeksforgeeks.html will be created in the home directory as soon as we execute the command. The image shown below is the output displayed in the created html file.

    Output:

  • -disable TEST, -enable TEST : This option is used to enable or disable a test like pci, isapnp, cpuid, usb, network, dmi, device-tree, cpuinfo, spd, etc.

    Example: To enable pci.

    Input:

    Output:

  • -quiet: This option is used when the user don’t want lshw to display status.
  • -sanitize: This option is used to sanitize output i.e. when we don’t want sensitive information like serial numbers, etc to be displayed.

    Example: To check hardware information without the serial number or any other sensitive information.

    Input:

    Output:

    You can see in the fourth line of the above output, the serial number is not displayed instead it shows [REMOVED].

  • -numeric: This option is used to when the user also want lshw to display numeric IDs (for PCI, USB, etc.)

    Example: To check numeric IDs of class disk.

  • -version: Displays the version of lshw and exits.

  • –help: Display help related information, available command line options and exit.


Last Updated : 23 May, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads