lshw command in Linux with Examples
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.
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.
Example 2: Lists hardware in a compact format.
- -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.
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.
- -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.
- -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.
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.