Exploring Hardware Information on Linux with lspci, lshw, and inxi
When managing a Linux system, it's often necessary to gather detailed information about the hardware components. Three powerful tools for this purpose are lspci, lshw, and inxi. Each of these commands provides different levels of detail and focuses on various aspects of the hardware.Using lspci
The lspci command lists all PCI devices on your system. This includes information about graphics cards, network adapters, and other peripherals connected via the PCI bus.Basic Usage:
Code:
lspci
Common Flags:
- -v: Provides verbose output with more detailed information.
Code:
lspci -v
- -s [bus:slot.func]: Shows information about a specific device.
Code:
lspci -s 00:1f.2
- -k: Displays the kernel driver handling each device.
Code:
lspci -k
Code:
lspci | grep -i net
CPU Example: While lspci is not typically used for CPU information, it can show related devices like the CPU bridge.
Code:
lspci | grep -i cpu
Using lshw
The lshw (list hardware) command provides detailed information about all hardware components. It can display information about memory, CPU, disks, and more.Basic Usage:
Code:
sudo lshw
Common Flags:
- -short: Displays a summary of hardware information.
Code:
sudo lshw -short
- -class [class]: Shows information about a specific class of hardware (e.g., memory, CPU).
Code:
sudo lshw -class memory
- -html: Outputs the information in HTML format.
Code:
sudo lshw -html > hardware_info.html
Code:
sudo lshw -class network
CPU Example: To get detailed information about the CPU, use the -class flag with cpu.
Code:
sudo lshw -class cpu
Using inxi
The inxi command is a versatile system information tool that provides a comprehensive overview of your system's hardware and software.Basic Usage:
Code:
inxi
Common Flags:
- -F: Displays full information about the system.
Code:
inxi -F
- -G: Shows detailed information about the graphics.
Code:
inxi -G
- -S: Provides system information including the kernel, uptime, and more.
Code:
inxi -S
Code:
inxi -N
CPU Example: To display detailed information about the CPU, use the -C flag.
Code:
inxi -C
Additional Tips
- Combining Commands: You can combine these commands with other tools like grep to filter specific information. For example, to find the memory size:
Code:
sudo lshw -class memory | grep size
- Updating PCI IDs: Ensure your PCI IDs are up-to-date for accurate lspci output:
Code:
sudo update-pciids
- Filtering Output: Use grep to filter the output of these commands for specific details. For example, to find the CPU model:
Code:
sudo lshw -class cpu | grep product
- Combining Commands: Combine commands to get a comprehensive overview. For example, to get both CPU and network information:
Code:
inxi -C -N