Lshw - List hardware
Lshw is a nifty small command line utility that generates detailed reports about various hardware components on the system. It does so by reading different files in the /proc directory.
Lshw is capable of reporting memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed etc.
Install lshw
Ubuntu, Debian users can get it from default repositories.
$ sudo apt-get install lshw
Fedora users can install it from the default repositories. On CentOS, lshw can be installed from Epel repository.
$ sudo yum install lshw
Using lshw - command examples
The lshw command needs to run with super privileges to be able to detect and report the maximum amount of information. So run as root, or use sudo.
Lshw assorts hardware components into groups called "class". Processor, memory, display, network, storage are all different classes.
1. Display full information
Running lshw without any options would generate full information report about all detected hardware. It would generate a big output with quite a lot of technical details
$ sudo lshw enlightened description: Desktop Computer product: () width: 64 bits capabilities: smbios-2.4 dmi-2.4 vsyscall32 configuration: boot=normal chassis=desktop uuid=949AC704-8C43-11DE-9395-000EA68F7260 *-core description: Motherboard product: DG35EC vendor: Intel Corporation physical id: 0 version: AAE29266-210 serial: BTEC934000EK slot: Base Board Chassis Location *-cpu description: CPU product: Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz vendor: Intel Corp. physical id: 0 bus info: cpu@0 version: Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz slot: LGA 775 size: 2664MHz capacity: 4GHz width: 64 bits clock: 333MHz capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority cpufreq ...TRIMMED
2. Display information in short
With the "-short" the lshw command would generate a brief information report about the hardware devices that would quickly give an idea about the hardware profile of the system.
$ sudo lshw -short H/W path Device Class Description =================================================== system () /0 bus DG35EC /0/0 processor Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz /0/0/1 memory 2MiB L2 cache /0/0/3 memory 32KiB L1 cache /0/2 memory 32KiB L1 cache /0/4 memory 64KiB BIOS /0/14 memory 8GiB System Memory /0/14/0 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/1 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/2 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/3 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/100 bridge 82G35 Express DRAM Controller /0/100/2 display 82G35 Express Integrated Graphics Controller /0/100/2.1 display 82G35 Express Integrated Graphics Controller /0/100/19 eth0 network 82566DC Gigabit Network Connection /0/100/1a bus 82801H (ICH8 Family) USB UHCI Controller #4 /0/100/1a.1 bus 82801H (ICH8 Family) USB UHCI Controller #5 /0/100/1a.7 bus 82801H (ICH8 Family) USB2 EHCI Controller #2 /0/100/1b multimedia 82801H (ICH8 Family) HD Audio Controller /0/100/1c bridge 82801H (ICH8 Family) PCI Express Port 1 /0/100/1c.1 bridge 82801H (ICH8 Family) PCI Express Port 2 /0/100/1c.2 bridge 82801H (ICH8 Family) PCI Express Port 3 /0/100/1c.2/0 storage JMB368 IDE controller /0/100/1d bus 82801H (ICH8 Family) USB UHCI Controller #1 /0/100/1d.1 bus 82801H (ICH8 Family) USB UHCI Controller #2 /0/100/1d.2 bus 82801H (ICH8 Family) USB UHCI Controller #3 /0/100/1d.7 bus 82801H (ICH8 Family) USB2 EHCI Controller #1 /0/100/1e bridge 82801 PCI Bridge /0/100/1e/5 bus FW322/323 [TrueFire] 1394a Controller /0/100/1f bridge 82801HB/HR (ICH8/R) LPC Interface Controller /0/100/1f.2 storage 82801H (ICH8 Family) 4 port SATA Controller [IDE mode] /0/100/1f.3 bus 82801H (ICH8 Family) SMBus Controller /0/100/1f.5 storage 82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE m /0/1 scsi3 storage /0/1/0.0.0 /dev/sda disk 500GB ST3500418AS /0/1/0.0.0/1 /dev/sda1 volume 70GiB Windows NTFS volume /0/1/0.0.0/2 /dev/sda2 volume 395GiB Extended partition /0/1/0.0.0/2/5 /dev/sda5 volume 97GiB HPFS/NTFS partition /0/1/0.0.0/2/6 /dev/sda6 volume 97GiB Linux filesystem partition /0/1/0.0.0/2/7 /dev/sda7 volume 1952MiB Linux swap / Solaris partition /0/1/0.0.0/2/8 /dev/sda8 volume 198GiB Linux filesystem partition /0/3 scsi4 storage /0/3/0.0.0 /dev/cdrom disk DVD RW DRU-190A
The above output is easy to interpret. The system has an intel processor, 4 RAM slots, 1 500gb hard drive with 6 partitions, 1 dvd writer, 1 network adapter, couple of usb ports etc.
The 3rd column is the class name. Lshw can display information only about a particular class if requested with the "-class" options.
3. Display only memory information
To display information about the memory, specify the memory class
$ sudo lshw -short -class memory H/W path Device Class Description =================================================== /0/0/1 memory 2MiB L2 cache /0/0/3 memory 32KiB L1 cache /0/2 memory 32KiB L1 cache /0/4 memory 64KiB BIOS /0/14 memory 8GiB System Memory /0/14/0 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/1 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/2 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/3 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
4. Display processor information
With class processor, lshw would display information about the cpu. It is better to not use the short option and get full details about the processor.
$ sudo lshw -class processor *-cpu description: CPU product: Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz vendor: Intel Corp. physical id: 0 bus info: cpu@0 version: Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz slot: LGA 775 size: 2664MHz capacity: 4GHz width: 64 bits clock: 333MHz capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority cpufreq
It should be noted that lshw does not accurately tell about the number of cores or processing units available. The above system for example is a quadcore processor with 4 processing units. Another command called lscpu gives more accurate information about the cpu.
Check out the following post:
8 commands to check cpu information on Linux
5. Disk drives
Display the disk drives with the disk class.
$ sudo lshw -short -class disk [sudo] password for enlightened: H/W path Device Class Description =================================================== /0/1/0.0.0 /dev/sda disk 500GB ST3500418AS /0/3/0.0.0 /dev/cdrom disk DVD RW DRU-190A
To display information about the partitions and controllers also, specify the storage and volume class along with the disk class. Then it would give a more clear picture about the storage on the system.
$ sudo lshw -short -class disk -class storage -class volume H/W path Device Class Description =================================================== /0/100/1c.2/0 storage JMB368 IDE controller /0/100/1f.2 storage 82801H (ICH8 Family) 4 port SATA Controller [IDE mode] /0/100/1f.5 storage 82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE m /0/1 scsi3 storage /0/1/0.0.0 /dev/sda disk 500GB ST3500418AS /0/1/0.0.0/1 /dev/sda1 volume 70GiB Windows NTFS volume /0/1/0.0.0/2 /dev/sda2 volume 395GiB Extended partition /0/1/0.0.0/2/5 /dev/sda5 volume 97GiB HPFS/NTFS partition /0/1/0.0.0/2/6 /dev/sda6 volume 97GiB Linux filesystem partition /0/1/0.0.0/2/7 /dev/sda7 volume 1952MiB Linux swap / Solaris partition /0/1/0.0.0/2/8 /dev/sda8 volume 198GiB Linux filesystem partition /0/3 scsi4 storage /0/3/0.0.0 /dev/cdrom disk DVD RW DRU-190A
6. Network adapter information
Use the network class to display information about the network adapter/interface. Omitting the short option is a good idea to get detailed information about it.
$ sudo lshw -class network *-network description: Ethernet interface product: 82566DC Gigabit Network Connection vendor: Intel Corporation physical id: 19 bus info: pci@0000:00:19.0 logical name: eth0 version: 02 serial: 00:1c:c0:f8:79:ee size: 100Mbit/s capacity: 1Gbit/s width: 32 bits clock: 33MHz capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=2.3.2-k duplex=full firmware=1.1-0 ip=192.168.1.2 latency=0 link=yes multicast=yes port=twisted pair speed=100Mbit/s resources: irq:43 memory:e0300000-e031ffff memory:e0324000-e0324fff ioport:20c0(size=32)
The value of the "serial" field is same as the MAC address. The configuration field indicates that autonegotiation is turned on and the current operating speed is 100Mbit/s. These configurations can be modified with the ethtool command.
7. Display address details with businfo
With the businfo option lshw would output the address details of pci, usb, scsi and ide devices
$ sudo lshw -businfo Bus info Device Class Description ===================================================== system () bus DG35EC cpu@0 processor Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz memory 2MiB L2 cache memory 32KiB L1 cache memory 32KiB L1 cache memory 64KiB BIOS memory 8GiB System Memory memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) pci@0000:00:00.0 bridge 82G35 Express DRAM Controller pci@0000:00:02.0 display 82G35 Express Integrated Graphics Controller pci@0000:00:02.1 display 82G35 Express Integrated Graphics Controller pci@0000:00:19.0 eth0 network 82566DC Gigabit Network Connection pci@0000:00:1a.0 bus 82801H (ICH8 Family) USB UHCI Controller #4 pci@0000:00:1a.1 bus 82801H (ICH8 Family) USB UHCI Controller #5 pci@0000:00:1a.7 bus 82801H (ICH8 Family) USB2 EHCI Controller #2 pci@0000:00:1b.0 multimedia 82801H (ICH8 Family) HD Audio Controller pci@0000:00:1c.0 bridge 82801H (ICH8 Family) PCI Express Port 1 pci@0000:00:1c.1 bridge 82801H (ICH8 Family) PCI Express Port 2 pci@0000:00:1c.2 bridge 82801H (ICH8 Family) PCI Express Port 3 pci@0000:03:00.0 storage JMB368 IDE controller pci@0000:00:1d.0 bus 82801H (ICH8 Family) USB UHCI Controller #1 pci@0000:00:1d.1 bus 82801H (ICH8 Family) USB UHCI Controller #2 pci@0000:00:1d.2 bus 82801H (ICH8 Family) USB UHCI Controller #3 pci@0000:00:1d.7 bus 82801H (ICH8 Family) USB2 EHCI Controller #1 pci@0000:00:1e.0 bridge 82801 PCI Bridge pci@0000:04:05.0 bus FW322/323 [TrueFire] 1394a Controller pci@0000:00:1f.0 bridge 82801HB/HR (ICH8/R) LPC Interface Controller pci@0000:00:1f.2 storage 82801H (ICH8 Family) 4 port SATA Controller [IDE mode] pci@0000:00:1f.3 bus 82801H (ICH8 Family) SMBus Controller pci@0000:00:1f.5 storage 82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE scsi3 storage scsi@3:0.0.0 /dev/sda disk 500GB ST3500418AS scsi@3:0.0.0,1 /dev/sda1 volume 70GiB Windows NTFS volume scsi@3:0.0.0,2 /dev/sda2 volume 395GiB Extended partition /dev/sda5 volume 97GiB HPFS/NTFS partition /dev/sda6 volume 97GiB Linux filesystem partition /dev/sda7 volume 1952MiB Linux swap / Solaris partition /dev/sda8 volume 198GiB Linux filesystem partition scsi4 storage scsi@4:0.0.0 /dev/cdrom disk DVD RW DRU-190A
The output is similar to "short" option, with the first column replaced with Bus Info.
8. Generate report in html/xml format
Lshw is capable of producing reports in html, xml and json formats.
$ sudo lshw -html > hardware.html
For xml format
$ sudo lshw -xml > hardware.xml
Summary
The above examples covered nearly most of what lshw can do. Check out the man page for full documentation.
Lshw also comes with a gui frontend called lshw-gtk that reports the same information in a minimal graphical user interface. Here is a screenshot.
There are many other gui tools for checking hardware information, like hardinfo that generate report in a more well organised manner and visually rich format.
Besides lshw there are many other commands that can be used to check hardware information on linux like inxi, lscpu, hwinfo etc.
Check out the following post to learn more:
https://www.binarytides.com/linux-commands-hardware-info/
If you have any other questions or feedback, let us know in the comments below:
Thanks Alot!
theres a glitch in lshw that produces plaintext when -html is selected with -businfo
GRAZIE!!!