As a Linux system administrator, having an in-depth understanding of your hardware configuration is critical for troubleshooting issues, upgrading components, and ensuring compatibility with software. Linux offers various built-in commands and tools to fetch intricate details about CPU, memory, disks, peripherals, and more.

In this comprehensive guide, we will explore the most useful commands to extract hardware information on Linux, including lsusb, lshw, dmidecode, lscpu, lspci, and more.

Overview of Key Hardware Information Commands on Linux

Here is a quick overview of the main hardware information commands we will cover:

  • lsusb – List USB devices connected to the system
  • lshw – List detailed hardware configuration of the entire system
  • dmidecode – Fetch data from system DMI/SMBIOS tables
  • lscpu – Show detailed CPU architecture and attributes
  • lspci – List all PCI devices connected to the system
  • lsblk – List block storage devices and their partitions
  • hdparm – Fetch or set SATA and IDE device parameters

Now let‘s look at each of these useful commands in more detail.

lsusb – Listing USB Devices

The lsusb command prints information about USB buses and connected USB devices in your system. With no arguments, it produces output like this:

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 058f:9540 Alcor Micro Corp. Flash Drive
Bus 001 Device 003: ID 04f2:b616 Chicony Electronics Co., Ltd USB 2.0 Camera
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

This gives you a tree view of the USB controllers, hubs, and devices connected to your system.

Some key points about the output:

  • The bus and device numbers identify the USB hierarchy.
  • The vendor ID (VID) and product ID (PID) uniquely identify each USB device.
  • The vendor and product description come from a central USB database.

To show more details on specific devices, use the -v option:

$ lsusb -v

Bus 001 Device 004: ID 058f:9540 Alcor Micro Corp. Flash Drive
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  ...

This displays the full USB device descriptors which include product name, supported USB standards, power requirements, and more technical details.

So in summary, lsusb is invaluable for inspecting USB devices, troubleshooting connectivity issues, finding VID/PID codes, and verifying device drivers.

lshw – Hardware Configuration in Detail

The lshw (list hardware) command generates a detailed report of the hardware configuration of the entire system.

A basic lshw output looks similar to this:

$ sudo lshw

*-memory
     description: System memory
     physical id: 0
     size: 16GiB
*-cpu
     product: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
     vendor: Intel Corp.
     physical id: 1
     bus info: cpu@0
     size: 400MHz
     capacity: 4000MHz
     width: 64 bits
...

As you can see, it displays a tree-like overview of memory, CPU, buses, storage, network adapters, peripherals, and more.

Using -short gives an abbreviated summary, while -html generates a hardware report in HTML format for saving and sharing.

Some key facts about lshw:

  • Needs root privileges to show all information
  • Extracts data from /proc, /sys and other system files
  • Has tons of options for customizing output
  • Helps get details for troubleshooting and diagnosing hardware issues

So in a nutshell, lshw gives you an exhaustive overview of your system‘s hardware configuration through a single command.

dmidecode – Fetching DMI/SMBIOS Data

The dmidecode command analyzes and reports data from system DMI (Desktop Management Interface) and SMBIOS (System Management BIOS) tables. These contain valuable details about system components and configuration.

For instance, to view system information, use:

$ sudo dmidecode -t system

# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.2.1 present.

Handle 0x0001, DMI type 1, 27 bytes
System Information
    Manufacturer: HP
    Product Name: ProDesk 600 G1 SFF
    Version: Not Specified
    Serial Number: 2UA6260JKR
    ...

This extracts information like manufacturer, model, serial number, hardware UUID, and more from DMI.

Similarly, other useful dmidecode types include:

  • BIOS – Firmware features and settings
  • Baseboard – Motherboard details
  • Processor – CPU specifications
  • Memory – RAM module attributes

So in short, dmidecode reads low-level system DMI/SMBIOS data that is useful for detailed hardware audits and reporting.

lscpu – CPU Architecture Information

The lscpu command gathers CPU architecture details by extracting data from /proc/cpuinfo and /sys virtual filesystem.

Running it displays output like the following:

$ lscpu

Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              16
On-line CPU(s) list: 0-15
Thread(s) per core:  2
Core(s) per socket:  8
...

This covers useful processor attributes like architecture, address sizes, number of cores/threads, sockets, NUMA modes, virtualization features, and more.

Some key points about lscpu:

  • No special permissions required to run
  • Great for understanding processor topology
  • Helps determine CPU capabilities and limits

So in summary, lscpu is the go-to command for inspecting detailed CPU configuration in Linux systems.

lspci – Listing PCI Devices

The lspci utility prints information on Peripheral Component Interconnect (PCI) buses and devices in the system.

A standard lspci output looks like this:

$ lspci 

00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 08)
00:01.0 PCI bridge: Intel Corporation 631xESB/632xESB/3100 Chipset PCI Express Root Port 1 (rev 09)
00:14.0 USB controller: Intel Corporation 100 Series/C230 Series Chipset Family USB 3.0 xHCI Controller
01:00.0 VGA compatible controller: NVIDIA Corporation GP107GL [Quadro P400] (rev a1)
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)

This lists the PCI device name, class, bus path, vendor details, and other attributes.

Additional options like -v, -s, -nn, -D can provide more descriptive names, show kernel drivers, display numeric IDs, and visualize device tree relationships respectively.

So to summarize, lspci is great for gaining insights into PCI devices, troubleshooting issues, determining hardware resources, and identifying devices.

lsblk – List Block Devices

The lsblk command lists information about all available block devices, which are mainly storage media like hard disk drives and SSDs.

A simple lsblk output displays details like this:

$ lsblk

NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0   1.8T  0 disk  
├─sda1        8:1    0   512M  0 part  /boot/efi
├─sda2        8:2    0     1K  0 part  
└─sda5        8:5    0   1.8T  0 part  
  ├─centos-root 253:0    0    50G  0 lvm   /
  ├─centos-swap 253:1    0     8G  0 lvm   
  └─centos-home 253:2    0   1.7T  0 lvm   /home

This covers essential details like device names, sizes, types (disk, partition, RAID, LVM etc), label, file system, mount points, and more.

Additional options like -f, -m, -o, -e can show serial numbers, node paths, UUIDs, and exclude certain devices from output.

So in summary, lsblk gives you a birds-eye view of storage devices and their layout, very useful for configuration analysis and managing filesystems.

hdparm – Tuning SATA/IDE Hard Disks

The hdparm utility can tune various storage device parameters for SATA, IDE, SCSI type disks and CD/DVD-ROMs.

For example, to view details of the first SATA drive on the system, run:

$ sudo hdparm -I /dev/sda

/dev/sda:

ATA device, with non-removable media
        Model Number:       WDC WD10EZEX-22MFCA0
        Serial Number:      WD-WCC7K4ZPZ8YY
        Firmware Revision:  80.00A80
Standards:
        Used: ATA/ATAPI-7 published, ANSI INCITS 397-2005
...

This shows the model name, serial number, standards support, caching modes, power modes, and more for the given device.

In addition, hdparm can do performance benchmarking, set SPI/DMA transfer modes, adjust power management settings, and various other storage device-specific operations.

So in essence, hdparm is invaluable for studying and tuning the advanced features of SATA/IDE storage devices in Linux.

Bonus: Useful Commands for Hardware Troubleshooting

Here are some bonus handy commands when dealing with Linux hardware and diagnosing issues:

  • dmesg – Print kernel ring buffer with hardware events/messages
  • journalctl -k – Show kernel logs for troubleshooting
  • free – Display system memory usage statistics
  • smartctl – Check S.M.A.R.T health indicators of storage drives
  • stress – Stress test CPU, memory, disk I/O to uncover issues
  • hwinfo – Probe for hardware details on parallel ports, scanners, printers etc

Conclusion

Getting extensive hardware information is vital for Linux admins to manage systems effectively. As we have seen in this guide, Linux offers various tools like lshw, lscpu dmidecode, lsusb, lspci, and more to extract intricate configuration details of CPU, memory, storage, peripherals and other components.

So if you found this useful, be sure to memorize and utilize these handy commands for analyzing hardware, troubleshooting issues, upgrading systems and more!

Similar Posts