lscpu Command Cheat Sheet
lscpu gathers CPU architecture information from sysfs and /proc/cpuinfo. It displays the number of threads, cores, sockets, and NUMA nodes, as well as CPU caches and family/model.
Synopsis
lscpu [OPTIONS]
Basic Output
lscpu
x86_64 (64-bit) or aarch64 (ARM).
- CPU(s): Total logical CPUs (Threads).
- Thread(s) per core: Hyper-threading (usually 1 or 2).
- Core(s) per socket: Physical cores per CPU package.
- Socket(s): Number of physical CPU chips.
- Virtualization: VT-x or AMD-V (Important for VMs).
- Hypervisor vendor: If you are inside a VM (e.g., KVM, VMware).
Specific Information
Extended Readable Output (-e)
Shows a table of all online CPUs with their assignments.
lscpu -e
Parseable Output (-p)
CSV-friendly format, easier for scripts.
lscpu -p
# CPU,Core,Socket,Node,,L1d,L1i,L2,L3
0,0,0,0,,0,0,0,0
JSON Output (-J)
Modern JSON format for automation.
lscpu -J
Filtering
Show Online/Offline CPUs
In hot-pluggable systems, some CPUs might be offline.
lscpu --online # Default
lscpu --offline
Show Caches
Displays sizes of L1, L2, L3 caches.
lscpu | grep -i cache
Practical Examples
Calculate Physical Cores
Total logical CPUs is simpler to find, but for licensing or performance, you often need physical cores.
lscpu | grep "Core(s) per socket"
lscpu | grep "Socket(s)"
Check Virtualization Support
Can I run KVM/VirtualBox?
lscpu | grep Virtualization
# Output: Virtualization: VT-x
Notes
- Byte Order: Shows Little Endian (Intel/AMD) or Big Endian.
- Flags: The "Flags" section lists instruction sets supported (e.g.,
avx,sse,aes). - Bogomips: A meaningless metric for speed, used only for kernel calibration.