lshw (list hardware) command is a small tool that generates detailed reports about various hardware components, including CPU version, memory configuration, cache information, bus speed, etc. on the system.
- lshw command is able to do so because it reads various files located in the /proc directory.
- To display complete information you must be root user or super user. Else it will print partial information.
Syntax of lshw Command
lshw [format] [options]
Format:
- -html: Output hardware tree as HTML
- -xml: Output hardware tree as XML
- -json: Output hardware tree as a JSON object
- -short: Output hardware paths
- -businfo: Output bus information
Options:
- class: Only show a certain class of hardware
- enable: Enable a test (like pci, isapnp, cpuid, etc. )
- disable: Disable a test (like pci, isapnp, cpuid, etc. )
- quiet: Don’t display status
- sanitize: Sanitize output (remove sensitive information like serial numbers, etc.)
- numeric: Output numeric IDs (for PCI, USB, etc.)
- notime: Exclude volatile attributes (timestamps) from output
Display full hardware information
To display complete hardware information use lshw command without any options and format.
sudo lshw
![sudo lshw command in linux](https://www.programbr.com/wp-content/uploads/2023/03/sudo-lshw-500x126.png)
lshw help
To get help related to “lshw” command, use the command “lshw –help”. It will help you find the format and options available with “lshw” command.
lshw --help
![lshw --help command in linux](https://www.programbr.com/wp-content/uploads/2023/03/lshw-help-500x245.png)
lshw format
Display hardware path
Use “lshw” command followed by “-short” to display hardware path in a compact format.
sudo lshw -short
![sudo lshw -short command in linux](https://www.programbr.com/wp-content/uploads/2023/03/sudo-lshw-short-500x138.png)
Display information in HTML
Use “lshw” command followed by “-html” to display hardware information in HTML format.
sudo lshw -html
![lshw html](https://www.programbr.com/wp-content/uploads/2023/03/lshw-html-programbr-500x422.png)
Display information in XML format
Use “lshw” command followed by “-xml” to display hardware information in XML format.
sudo lshw -xml
![sudo lshw -xml command in linux](https://www.programbr.com/wp-content/uploads/2023/03/sudo-lshw-xml-500x243.png)
Display bus information
Use “lshw” command followed by “-businfo” to display the bus information. It provides more information about the SCSI, USB, IDE, PCI etc.
lshw -businfo
![lshw -businfo command in linux](https://www.programbr.com/wp-content/uploads/2023/03/lshw-businfo-500x218.png)
lshw options
sudo lshw -class disk -numeric
lshw command with -disable option allow us to disable various parameter’s functionality .
Here I am disabling cpuid.
sudo lshw -disable cpuid
lshw command with -enable option allow us to enable various parameter’s functionality.
Here I am enabling cpuid.
sudo lshw -enable cpuid
sudo lshw -quiet
sanitize is used, When users don’t wish to display sensitive information. Use the lshw command with -sanitize option to hide sensitive information like serial numbers, IP addresses etc.
sudo lshw -sanitize
Linux command with examples
A
adduser | addgroup | alias | anacron | apt | aptitude | arp | at | atq | atrm | awk
B
basename | banner | batch | bc | bg | bzip
C
cat | cal | cd | chgrp | chown | cksum | chmod | clear | cmp | comm | cp
D
date | dd | df | diff | dir | dmidecode | du
E
echo | eject | env | exit | expr
F
G
grep | groups | gunzip | gzip
H
head | history | hostname | hostnamectl | htop | hwclock | hwinfo
I
id | ifconfig | ionice | iostat | ip | iptables | iw | iwlist
J
K
kill | kmod
L
last | less | ln | locate | login | lp | ls | lshw | lscpu | lsof | lsusb
M
man | mdsum | mkdir | more| mv
N
nano | nc | neofetch | netcat | netstat | nice | nmap | nproc
O
openssl
P
passwd | pidof | ping | pr | ps | pwd | pstree
Q
R
rdiff-backup | reboot | rename | rm | rmdir
S
scp | shred | shutdown | sleep | sort | split | ssh | stat | su | sudo | sum
T
tac | tail | talk | tar | tee | time | tree | top | touch | tr
U
unalias | uname | uniq | unzip | uptime | users
V
vim | vi
W
w | wall | watch | wc | wget | whatis | whereis | which | who | whoami
X
xargs
Y
yes | youtube-dl
Z
zcmp | zdiff | zip | zz