lshw command in Linux with examples

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“.

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.

lshw description of the Laptop
Command:
# lshw

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.

lshw -class cpu is used to find the detail of Information
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.

  • For CPU
  • For Ram
  • For Network
  • For Disk
  • For volume
Command to Check CPU
# lshw -short -class cpu
To Check RAM
# lshw -short -class memory
Command For Network
# lshw -short -class network
For the Disk
# lshw -short -class disk
Command: To Check volume
# lshw -short -class volume
-html option is used to show the output in HTML format.
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.

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.

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
  • For Disks
  • For CPUS

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 -sanitize
Command: To remove the Sensitive Information of DISK
# lshw -class disk -sanitize
lshw command in Linux cheat sheet
To List all the HARDWARE in your current System

Example:
#lshw
To make the output short with lshw command 

Example:
#lshw -short 
To search by the TYPE of Hardware 

Example:
#lshw -class cpu          ** This is for CPU **
#lshw -class memory  ** This is for RAM **
#lshw -class disk          ** This is for DISK **
#lshw -class volume    ** This is for partition **
#lshw -class network  ** This is for Network **
To hide the sensitive Information like serail number. 

Example:
#lshw -sanitize
#lshw -class cpu -sanitize 
#lshw -class memory -sanitize 
#lshw -class disk  -sanitize
#lshw -class volume  -sanitize
#lshw -class network  -sanitize
To get the output in HTML Format 

Example:
#lshw -html

** To take a html format in one file **
#lshw -html > hardware_list.html 
To get the output in XML Format 

Example:
#lshw -xml

** To take a xml format in one file **
#lshw -xml > hardware_list.xml 
To get the output in JSON Format 

Example:
#lshw -json

** To take a json format in one file **
#lshw -json > hardware_list.json 

0%

Did the lshw command is used to list the hardware?

Correct! Wrong!

Can we check the process with lshw command?

Correct! Wrong!

Which option we can use to make our output short?

Correct! Wrong!

Which option is used to hide the sensitive information?

Correct! Wrong!

Which option to be used to check the output by it's type?

Correct! Wrong!

lshw command Quiz, Let's Play and check your Grip
Thanks for your valuable time!
To Learn more Basic command you can go to "LINUX BASIC COMMAND SECTION" and Spread the Knowledge Keep Supporting us! Follow us on our ID's: >> Instagram: @tastethelinux_official >>Facebook: https://fb.me/tastethelinuxofficial >>Twitter: @LinuxTaste

Share your Results:

To Learn more Basic commands click on Blue one, Learn free , du, df also.

One Reply to “lshw command in Linux with examples”

Give your valuable time