Hi Friends! Today we learn lshw command in Linux with Examples.
lshw command is mainly used to check the list of hardware and Configuration in your server and PC.
But while using lshw command got the error like “lshw command not found“.
You can see in the screenshot that lshw command not found, So we have to install the lshw command in centos
#yum install lshw -y
Same we can install the lshw command in Ubuntu by using apt
#apt install lshw
So after installation, now we can use the lshw command in our Terminal.Command:
But the output is very huge, so we will use -short option with
-short to make the output short
# lshw -short Output H/W path Device Class Description ===================================================== system VirtualBox /0 bus VirtualBox /0/0 memory 128KiB BIOS /0/1 memory 2GiB System memory /0/2 processor Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz /0/100 bridge 440FX - 82441FX PMC [Natoma] /0/100/1 bridge 82371SB PIIX3 ISA [Natoma/Triton II] /0/100/1.1 scsi1 storage 82371AB/EB/MB PIIX4 IDE /0/100/1.1/0.0.0 /dev/cdrom disk CD-ROM /0/100/2 display VirtualBox Graphics Adapter /0/100/3 enp0s3 network 82540EM Gigabit Ethernet Controller /0/100/4 generic VirtualBox Guest Service /0/100/5 multimedia 82801AA AC'97 Audio Controller /0/100/6 bus KeyLargo/Intrepid USB /0/100/6/1 usb1 bus OHCI PCI host controller /0/100/7 bridge 82371AB/EB/MB PIIX4 ACPI /0/100/d scsi2 storage 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] /0/100/d/0.0.0 /dev/sda disk 21GB VBOX HARDDISK /0/100/d/0.0.0/1 volume 19GiB Linux filesystem partition /1 virbr0-nic network Ethernet interface /2 virbr0 network Ethernet interface
-class option to show only the specific class of Hardware.Command:
# lshw -class CPU
Let’s use -short option with -class option and get the output for the processor, memory, a disk with volume, and a network.Command to Check CPU
# lshw -short -class cpuTo Check RAM
# lshw -short -class memoryCommand For Network
# lshw -short -class networkFor the Disk
# lshw -short -class diskCommand: To Check volume
# lshw -short -class volume
-html option is used to show the output in HTML format.
We get all the hardware lists in HTML format and we can save that into a file. By using the below command.Command: To take dump in HTML Format
# lshw -html > hardware_list.html
-xml option is used to show the output in xml format.
We get all the hardware lists in XML format and we can save that into a file. By using the below command.
-json option is used to show the output in json format.
We get all the hardware lists in JSON format and we can save that into a file. By using the below command.Command: To take dump in JSON Format
# lshw -json > hardware_list.json
-sanitize option is used to hide sensitive information from the output.
We can use this command to hide the information like serial Number.Command:
# lshw -sanitize
The above output we have a yellow highlighted part and there is a parameter like “serial: [REMOVED]”Command: To remove the Sensitive Information of CPU
# lshw -class cpu -sanitizeCommand: To remove the Sensitive Information of DISK
# lshw -class disk -sanitize
lshw command in Linux cheat sheet