Ok lets say you get into a office from a customer and you have to familiarize yourself as quick as possible with what kind of systems the customer is running in its datacenter. You can do a lot by looking at the operating system however at some point you also want to know what kind of hardware is located in the datacenter, what hardware are those systems are running on. You can quickly see a lot of stuff like memory, CPU and storage however if you want to dive into more detail of the hardware you will find your friend in the lshw command.
lshw stands for list hardware and enables you to list all the hardware on your system. lshw comes in a commandline version and a graphical version. We will focus on the commandline version.
lshw has a couple of options, the first which we will not discuss is the -X command, this will launch the GUI of lshw which we will not discuss. What are great options when you need to index a lot of systems in a short time are the -xml and the -html command. The -html command will generate a very basic command which you could use to generate per server a hardware information page, if you want to do more than only view it and you want to import it in a database for example you can use the -xml option to generate the same content in a xml way.
The -short and -businfo options are more for when you need a quick glimps into the hardware. This is commonly used when you will be debugging some problem which might be related to hardware.
A example of the output of the lshw -short command on one of my laptops is shown below;
root@JOLO-LINUX:~# lshw -short
H/W path Device Class Description
==========================================================
system 6464B88
/0 bus 6464B88
/0/0 memory 128KiB BIOS
/0/6 processor Intel(R) Core(TM)2 Duo CPU T7100 @ 1.80GHz
/0/6/a memory 64KiB L1 cache
/0/6/c memory 2MiB L2 cache
/0/6/0.1 processor Logical CPU
/0/6/0.2 processor Logical CPU
/0/b memory 64KiB L1 cache
/0/2b memory 2GiB System Memory
/0/2b/0 memory 1GiB SODIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/2b/1 memory 1GiB SODIMM DDR2 Synchronous 667 MHz (1.5 ns)
/0/1 processor
/0/1/0.1 processor Logical CPU
/0/1/0.2 processor Logical CPU
/0/100 bridge Mobile PM965/GM965/GL960 Memory Controller Hub
/0/100/2 display Mobile GM965/GL960 Integrated Graphics Controller
/0/100/2.1 display Mobile GM965/GL960 Integrated Graphics Controller
/0/100/19 eth0 network 82566MM 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.1/0 wlan0 network PRO/Wireless 4965 AG or AGN [Kedron] Network Connection
/0/100/1c.2 bridge 82801H (ICH8 Family) PCI Express Port 3
/0/100/1c.3 bridge 82801H (ICH8 Family) PCI Express Port 4
/0/100/1c.4 bridge 82801H (ICH8 Family) PCI Express Port 5
/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 Mobile PCI Bridge
/0/100/1e/0 bridge RL5c476 II
/0/100/1e/0.1 bus R5C832 IEEE 1394 Controller
/0/100/1e/0.2 generic R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter
/0/100/1e/0.3 generic Illegal Vendor ID
/0/100/1e/0.4 generic R5C592 Memory Stick Bus Host Adapter
/0/100/1e/0.5 generic xD-Picture Card Controller
/0/100/1f bridge 82801HBM (ICH8M-E) LPC Interface Controller
/0/100/1f.1 scsi0 storage 82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller
/0/100/1f.1/0.0.0 /dev/cdrom disk DVD/CDRW UJDA775
/0/100/1f.2 scsi2 storage 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller
/0/100/1f.2/0.0.0 /dev/sda disk 100GB HITACHI HTS72201
/0/100/1f.2/0.0.0/1 /dev/sda1 volume 35GiB Windows NTFS volume
/0/100/1f.2/0.0.0/2 /dev/sda2 volume 41GiB Windows NTFS volume
/0/100/1f.2/0.0.0/3 /dev/sda3 volume 16GiB Extended partition
/0/100/1f.2/0.0.0/3/5 /dev/sda5 volume 15GiB Linux filesystem partition
/0/100/1f.2/0.0.0/3/6 /dev/sda6 volume 760MiB Linux swap / Solaris partition
/0/100/1f.3 bus 82801H (ICH8 Family) SMBus Controller
/1 power 92P1141
root@JOLO-LINUX:~#
the output of the lshw -businfo command on the same machine is shown below;
root@JOLO-LINUX:~# lshw -businfo
Bus info Device Class Description
=====================================================
system 6464B88
bus 6464B88
memory 128KiB BIOS
cpu@0 processor Intel(R) Core(TM)2 Duo CPU T7100 @ 1.80GHz
memory 64KiB L1 cache
memory 2MiB L2 cache
processor Logical CPU
processor Logical CPU
memory 64KiB L1 cache
memory 2GiB System Memory
memory 1GiB SODIMM DDR2 Synchronous 667 MHz (1.5 ns)
memory 1GiB SODIMM DDR2 Synchronous 667 MHz (1.5 ns)
cpu@1 processor
processor Logical CPU
processor Logical CPU
pci@0000:00:00.0 bridge Mobile PM965/GM965/GL960 Memory Controller Hub
pci@0000:00:02.0 display Mobile GM965/GL960 Integrated Graphics Controller
pci@0000:00:02.1 display Mobile GM965/GL960 Integrated Graphics Controller
pci@0000:00:19.0 eth0 network 82566MM 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:03:00.0 wlan0 network PRO/Wireless 4965 AG or AGN [Kedron] Network Connection
pci@0000:00:1c.2 bridge 82801H (ICH8 Family) PCI Express Port 3
pci@0000:00:1c.3 bridge 82801H (ICH8 Family) PCI Express Port 4
pci@0000:00:1c.4 bridge 82801H (ICH8 Family) PCI Express Port 5
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 Mobile PCI Bridge
pci@0000:15:00.0 bridge RL5c476 II
pci@0000:15:00.1 bus R5C832 IEEE 1394 Controller
pci@0000:15:00.2 generic R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter
pci@0000:15:00.3 generic Illegal Vendor ID
pci@0000:15:00.4 generic R5C592 Memory Stick Bus Host Adapter
pci@0000:15:00.5 generic xD-Picture Card Controller
pci@0000:00:1f.0 bridge 82801HBM (ICH8M-E) LPC Interface Controller
pci@0000:00:1f.1 scsi0 storage 82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller
scsi@0:0.0.0 /dev/cdrom disk DVD/CDRW UJDA775
pci@0000:00:1f.2 scsi2 storage 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller
scsi@2:0.0.0 /dev/sda disk 100GB HITACHI HTS72201
scsi@2:0.0.0,1 /dev/sda1 volume 35GiB Windows NTFS volume
scsi@2:0.0.0,2 /dev/sda2 volume 41GiB Windows NTFS volume
scsi@2:0.0.0,3 /dev/sda3 volume 16GiB Extended partition
/dev/sda5 volume 15GiB Linux filesystem partition
/dev/sda6 volume 760MiB Linux swap / Solaris partition
pci@0000:00:1f.3 bus 82801H (ICH8 Family) SMBus Controller
power 92P1141
root@JOLO-LINUX:~#
you can use the lshw command itself without any extra option, this will show you a lot of information however that can be a little intimidating the first time you have a look at it. Better is to limit the output by using a class option. for example using the class option processor. Shown below is the output of the command lshw -class processor ;
root@JOLO-LINUX:~# lshw -class processor
*-cpu:0
description: CPU
product: Intel(R) Core(TM)2 Duo CPU T7100 @ 1.80GHz
vendor: Intel Corp.
physical id: 6
bus info: cpu@0
version: 6.15.13
serial: 0000-06FD-0000-0000-0000-0000
slot: None
size: 1801MHz
capacity: 1801MHz
width: 64 bits
clock: 200MHz
capabilities: boot fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx x86-64 constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm ida tpr_shadow vnmi flexpriority cpufreq
configuration: id=0
*-logicalcpu:0
description: Logical CPU
physical id: 0.1
width: 64 bits
capabilities: logical
*-logicalcpu:1
description: Logical CPU
physical id: 0.2
width: 64 bits
capabilities: logical
*-cpu:1
physical id: 1
bus info: cpu@1
version: 6.15.13
serial: 0000-06FD-0000-0000-0000-0000
size: 800MHz
capacity: 800MHz
capabilities: vmx ht cpufreq
configuration: id=0
*-logicalcpu:0
description: Logical CPU
physical id: 0.1
capabilities: logical
*-logicalcpu:1
description: Logical CPU
physical id: 0.2
capabilities: logical
root@JOLO-LINUX:~#
the class option can be used also on the other commands, below example is the -class option used on the -short option;
root@JOLO-LINUX:~# lshw -short -class processor
H/W path Device Class Description
==========================================================
/0/6 processor Intel(R) Core(TM)2 Duo CPU T7100 @ 1.80GHz
/0/6/0.1 processor Logical CPU
/0/6/0.2 processor Logical CPU
/0/1 processor
/0/1/0.1 processor Logical CPU
/0/1/0.2 processor Logical CPU
root@JOLO-LINUX:~#
shown below is the class option used on the -businfo option.
root@JOLO-LINUX:~# lshw -businfo -class processor
Bus info Device Class Description
=====================================================
cpu@0 processor Intel(R) Core(TM)2 Duo CPU T7100 @ 1.80GHz
processor Logical CPU
processor Logical CPU
cpu@1 processor
processor Logical CPU
processor Logical CPU
root@JOLO-LINUX:~#