In Ubuntu systems, understanding hardware configuration is fundamental for troubleshooting issues, installing software, or upgrading hardware. Today, we’ll learn two commonly used commands: lscpu and lspci, which help you quickly obtain detailed information about the CPU, memory, and various hardware devices.
1. lscpu: View CPU and Memory Information¶
lscpu is a very useful command for displaying CPU (including logical/physical cores, model, cache, etc.) and memory (total capacity, type, etc.) configurations. It reads system files like /proc/cpuinfo and /proc/meminfo and formats the output.
Basic Usage¶
Simply run lscpu in the terminal:
lscpu
If the command is not found (rarely), install the dependency package first:
sudo apt update && sudo apt install util-linux # util-linux contains the lscpu command
Key Parameters and Output Interpretation¶
The output of lscpu is extensive; focus on these core details:
| Parameter | Explanation |
|---|---|
| Architecture | System architecture (e.g., x86_64 for 64-bit) |
| CPU(s) | Total number of logical processors (includes hyper-threading; e.g., 4 cores/8 threads show 8) |
| Core(s) per socket | Number of cores per physical CPU socket (physical cores, hyper-threading excluded) |
| Socket(s) | Number of physical CPU sockets (usually 1 for laptops, 1-2 for desktops) |
| Model name | Specific CPU model (e.g., “Intel(R) Core(TM) i5-10400F”) |
| CPU MHz | Current CPU operating frequency (fluctuates; refer to “CPU max MHz” for peak frequency) |
| L1/L2/L3 cache | CPU cache sizes (L1 = primary cache, L3 = tertiary cache; larger caches generally mean better performance) |
| Memory(s) | Total memory capacity (e.g., “15Gi” = 15GB) |
Example:
If you see Model name: Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz, your CPU is an Intel i5-10400F with a base frequency of 2.9GHz. Core(s) per socket: 6 indicates 6 physical cores per socket, and CPU(s): 12 suggests hyper-threading is enabled (6 cores/12 threads).
2. lspci: View PCI Device Information¶
lspci lists all PCI (Peripheral Component Interconnect) bus devices, including graphics cards, network cards, sound cards, and hard disk controllers. It helps you quickly identify details like “Is my graphics card discrete?” or “What’s the network card model?”.
Basic Usage¶
Run lspci directly in the terminal:
lspci
If the command is not found, install the dependency package:
sudo apt update && sudo apt install pciutils # pciutils contains the lspci command
Common Parameters and Output Interpretation¶
lspci supports multiple parameters; common ones include:
| Parameter | Purpose |
|---|---|
-v |
Show detailed device information (e.g., drivers, memory addresses) |
-t |
Display devices in a tree structure (more intuitive) |
-nn |
Show hardware IDs (numeric format for quick model lookup, e.g., “[10de:2560]” for NVIDIA) |
-d=vendorID:deviceID |
Query devices from a specific vendor (e.g., -d=10de:0 shows only NVIDIA devices) |
Output Interpretation:
Each line follows the format [Bus Address] Device Type: Vendor Model (rev). For example:
00:02.0 VGA compatible controller: Intel Corporation Device 408e (rev 01)
01:00.0 VGA compatible controller: NVIDIA Corporation GA106M [GeForce RTX 3060 Mobile] (rev a1)
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 (rev 15)
- Bus Address:
00:02.0indicates the device’s position on the PCI bus (00 = bus number, 02 = device number, 0 = function number). - Device Type:
VGA compatible controller= graphics card,Ethernet controller= wired network card,Network controller= wireless network card. - Vendor/Model:
Intel Corporation,NVIDIA Corporation,Realtekhelp identify hardware vendors.
Example:
Using lspci -nn to check graphics cards might show:
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA106M [GeForce RTX 3060 Mobile] [10de:2560] (rev a1). Here, [10de:2560] is NVIDIA’s device ID, which can be queried on websites like PCIVendorID.com for specific model details.
Practical Tips¶
- Save Output: Redirect results to files for later review or sharing:
lscpu > cpu_info.txt # Save CPU info to cpu_info.txt
lspci > pci_info.txt # Save PCI device info to pci_info.txt
-
Filter Graphics Cards: Use
lspci -vnn | grep -i vgato display only graphics card details. -
Tree Structure:
lspci -tvisualizes device connections like a “hardware family tree” (e.g., motherboard → CPU → graphics card → network card).
Summary¶
- lscpu: Focuses on CPU and memory, ideal for quickly confirming “Is my CPU sufficient? Is memory enough?”
- lspci: Covers all PCI devices (graphics cards, network cards, sound cards, etc.), useful for troubleshooting “Is my graphics card discrete?” or “What’s the network card model?”.
With these two commands, you can comprehensively understand your Ubuntu system’s hardware configuration in minutes—whether verifying compatibility before software installation or diagnosing hardware issues. For parameter-specific questions, consult man lscpu or man lspci for detailed documentation!