Find the installed Hardware info in Ubuntu

Like listing the directories and files using the “ls” command, we can list hardware in the system using the “lshw” command. Various filters are available to filter the result of the “lshw” command based on the type of hardware, like disk, processor, etc. Please see the below examples and follow along. Note that to use the “lshw” command, you should run it as a “root” user; otherwise, the result would be partial or may be incorrect.

For example, WARNING when “lshw” is used by non-root user:

lshw -short
WARNING: you should run this program as super-user.
H/W path Device Class Description
=========================================================
/0/100/1b/0/0/1 /dev/nvme0n1 disk NVMe namespace
WARNING: output may be incomplete or inaccurate, you should run this program as a super-user.Now see the example command and output to get various installed hardware info:
To get the installed disk info:
sudo lshw -class disk -short
H/W path Device Class Description
=============================================================
/0/100/1b/0/0/1 /dev/nvme0n1 disk 1024GB NVMe namespace
/0/9/0.0.0 /dev/sda disk 1TB SSD 870 QVO 1TB

To list the partitions of each disk from the above command:
lsblk /dev/sda
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 1007K 0 part
├─sda2 8:2 0 512M 0 part
└─sda3 8:3 0 931G 0 part


lsblk /dev/nvme0n1
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 953.9G 0 disk
├─nvme0n1p1 259:1 0 260M 0 part /boot/efi
├─nvme0n1p2 259:2 0 16M 0 part
├─nvme0n1p3 259:3 0 304.1G 0 part
├─nvme0n1p4 259:4 0 341.2G 0 part /mnt/windows/d
├─nvme0n1p5 259:5 0 995M 0 part
└─nvme0n1p6 259:6 0 307.4G 0 part /

Get the processor Info:
sudo lshw -short -class processor
H/W path Device Class Description
=============================================================
/0/51 processor Intel(R) Core(TM) i7-XXXXX CPU @ 2.06GHz
ps@controller:~$
Get the NIC info:
sudo lshw -short -class network
H/W path Device Class Description
=============================================================
/0/100/14.3 wlo1 network Comet Lake PCH CNVi WiFi
/0/100/1f.6 eno2 network Ethernet Connection (11) I219-LM
ps@controller:~$
Get the installed RAM info:
sudo lshw -short -class memory
H/W path Device Class Description
=============================================================
/0/0 memory 64KiB BIOS
/0/3c memory 32GiB System Memory
/0/3c/0 memory 32GiB SODIMM DDR4 Synchronous 3200 MHz (0.3 ns)
/0/3c/1 memory [empty]
/0/4e memory 640KiB L1 cache
/0/4f memory 2560KiB L2 cache
/0/50 memory 20MiB L3 cache
/0/100/14.2 memory RAM memory
ps@controller:~$

Get the communication capabilities:
sudo lshw -short -sanitize -class communication
H/W path Device Class Description
=============================================================
/0/100/14/0/e communication AX201 Bluetooth
/0/100/16 communication Comet Lake HECI Controller
/0/100/16.3 communication Comet Lake Keyboard and Text (KT) Redirection

To print all the available class filters:

Then, you can filter the lshw command output based on these classes.

sudo lshw -short |awk -vFS='[ ][ ]+' 'NR>2{print $(NF-1)}'|awk '!a[$0]++'
system
bus
memory
processor
bridge
display
multimedia
generic
communication
storage
network
disk
volume
power
To get the output in JSON format:

Similarly, you may use XML format. Check the formats using the “man lshw” comm nd. Also, note that the “-sanitize” option is used to redact the sensitive information to print in the output.

sudo lshw -class disk -json -sanitize
Example:

 

0 0 votes
Please, Rate this post
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Scroll to Top