As Linux users, understanding what’s under the hood of our systems is crucial for troubleshooting, performance optimization, and general curiosity. While graphical tools offer some insights, the command line provides a powerful and often more detailed view. Today, we’ll explore four essential commands that every Linux user should know: lscpu
, lsusb
, lspci
, and lsblk
.
1. lscpu
: Your CPU’s Biography
The lscpu
command provides comprehensive information about your system’s CPU architecture. It gathers data from /proc/cpuinfo
and presents it in a human-readable format, making it easy to understand your processor’s capabilities.
Usage:
Simply type lscpu
in your terminal.
Example Output (abbreviated):
Architecture: x86_62
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
CPU family: 6
Model: 158
Stepping: 10
CPU MHz: 800.000
BogoMIPS: 7400.00
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 12M
Key information you can glean:
- Architecture: Whether it’s 32-bit or 64-bit.
- CPU(s): Total number of CPUs (cores and threads).
- Vendor ID & Model name: Manufacturer and specific model of your CPU.
- CPU MHz: Current operating frequency.
- Cache information: Details about L1, L2, and L3 caches.
- Virtualization: Whether hardware virtualization (VT-x or AMD-V) is supported.
2. lsusb
: Peeking at Your USB Devices
The lsusb
command lists all USB devices connected to your system. This is incredibly useful for identifying connected peripherals, troubleshooting device recognition issues, or simply seeing what’s plugged into your USB ports.
Usage:
lsusb
: Lists basic information about all connected USB devices.lsusb -v
: Provides verbose output, including detailed descriptors for each device.
Example Output (basic):
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 004: ID 0424:2514 Microchip Technology, Inc. USB 2.0 Hub
Bus 001 Device 003: ID 046d:0825 Logitech, Inc. Webcam C270
Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Understanding the output:
- Bus: The USB bus number.
- Device: The device number on that bus.
- ID: A unique vendor ID (VID) and product ID (PID) pair, often used to identify the device manufacturer and model.
- Description: A human-readable description of the device.
Example with verbose output (lsusb -v
):
This output is extensive, providing details like device class, sub-class, protocol, power consumption, and supported speeds. It’s excellent for in-depth debugging.
3. lspci
: Exploring Your PCI Devices
The lspci
command provides information about all PCI (Peripheral Component Interconnect) buses and devices connected to them. This includes your graphics card, network cards, sound cards, and other internal components.
Usage:
lspci
: Lists basic information about all PCI devices.lspci -v
: Provides verbose output with more details.lspci -vv
: Even more verbose output.lspci -k
: Shows kernel modules associated with each device.
Example Output (basic):
00:00.0 Host bridge: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers (rev 0b)
00:01.0 PCI bridge: Intel Corporation 6th-10th Gen Core Processor PCIe Controller (x16) (rev 0b)
00:02.0 VGA compatible controller: Intel Corporation CoffeeLake-S GT2 [UHD Graphics 630]
00:14.0 USB controller: Intel Corporation 200 Series/Z370 Chipset Family USB 3.0 xHCI Controller
00:16.0 Communication controller: Intel Corporation 200 Series/Z370 Chipset Family MEI Controller #1
00:17.0 SATA controller: Intel Corporation 200 Series PCH SATA controller [AHCI mode]
00:1f.3 Audio device: Intel Corporation 200 Series PCH HD Audio
00:1f.4 SMBus: Intel Corporation 200 Series/Z370 Chipset Family SMBus
01:00.0 VGA compatible controller: NVIDIA Corporation GP107 [GeForce GTX 1050 Ti] (rev a1)
Key information you can glean:
- Bus/Device/Function: The unique identifier for each PCI device.
- Device Description: A brief description of the device’s function.
- Vendor and Product IDs: Similar to
lsusb
, these IDs uniquely identify the manufacturer and product.
Example with kernel modules (lspci -k
):
01:00.0 VGA compatible controller: NVIDIA Corporation GP107 [GeForce GTX 1050 Ti] (rev a1)
Subsystem: ZOTAC International (MCO) Ltd. GP107 [GeForce GTX 1050 Ti]
Kernel driver in use: nvidia
Kernel modules: nouveau, nvidia_drm, nvidia
This output is particularly useful for verifying if the correct drivers are loaded for your hardware.
4. lsblk
: Mapping Your Block Storage Devices
The lsblk
command lists information about all available block devices (hard drives, SSDs, USB drives, partitions, etc.). It presents the information in a tree-like format, showing the relationships between disks and their partitions.
Usage:
lsblk
: Lists basic information in a tree format.lsblk -f
: Shows filesystem information (UUID, LABEL, FSTYPE, MOUNTPOINT).lsblk -a
: Shows all devices, including empty ones.lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT,UUID
: Specifies custom output columns.
Example Output (basic):
NAME MAJ:MIN RM SIZE RO type MOUNTPOINT
sda 8:0 0 238.5G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 237.4G 0 part
└─vgubuntu-root 253:0 0 237.4G 0 lvm /
sdb 8:16 1 7.5G 0 disk
└─sdb1 8:17 1 7.5G 0 part /media/user/USB_DRIVE
sr0 11:0 1 1024M 0 rom
Understanding the output:
- NAME: The device name (e.g.,
sda
,sdb
,sda1
,sr0
for CD/DVD). - MAJ:MIN: Major and minor device numbers.
- RM: Removable device (1 for removable, 0 for non-removable).
- SIZE: Size of the device or partition.
- RO: Read-only (1 for read-only, 0 for read-write).
- TYPE: Type of device (disk, part, lvm, rom).
- MOUNTPOINT: Where the device or partition is mounted in the filesystem.
Example with filesystem information (lsblk -f
):
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 vfat B701-4475 /boot/efi
├─sda2 ext4 b017b204-7a3d-4c3e-8f2e-0a0e2a3b4c5d /boot
└─sda3 LVM2_member n2aN1m-M2aE-d4bE-F3aE-t2mD-r2aE-q2aE
└─vgubuntu-root ext4 b3c2d1a0-e9f8-47c6-8f3a-2b1c0a0b9e8d /
sdb
└─sdb1 vfat USB_DRIVE C4D0-A2B0 /media/user/USB_DRIVE
sr0
This is extremely useful when dealing with mounting issues, identifying specific partitions by their UUIDs, or simply getting a complete overview of your storage layout.
Conclusion
The lscpu
, lsusb
, lspci
, and lsblk
commands are indispensable tools for any Linux user. They provide a quick, detailed, and command-line friendly way to inspect your system’s hardware configuration. By mastering these commands, you’ll be better equipped to troubleshoot problems, verify hardware installations, and gain a deeper understanding of your Linux machine. So next time you’re wondering what’s inside your computer, open your terminal and give these commands a try!