What it does
lscpu collects CPU data from /proc/cpuinfo and /sys. Useful lines: CPU(s), Thread(s) per core, Core(s) per socket, Socket(s), Model name, Hypervisor vendor, Virtualization, and the Vulnerability lines (Spectre, Meltdown …) with their mitigation status.
How to write it
lscpu [OPTION]...Options 15
Most used
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
1CPU overview
lscpu Architecture: x86_64 CPU(s): 2 Model name: Intel Xeon Processor (Icelake) Hypervisor vendor: KVMPlus sockets, cores, caches, flags.
2Cores and threads
lscpu | grep -E '^(CPU\(s\)|Thread|Core|Socket)'CPUs = sockets × cores × threads.
3Is this a VM?
lscpu | grep -i hypervisor Hypervisor vendor: KVMNo line = physical machine.
4Can it run VMs?
lscpu | grep -i virtualizationVT-x or AMD-V needed for KVM.
5CPU security mitigations (security)
lscpu | grep -i vulnerab Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS"Vulnerable" lines need a kernel or microcode update.
6Per CPU table
lscpu -eWhich CPU is on which core and socket.
7Caches
lscpu -CL1, L2, L3 sizes.
8JSON for inventory
lscpu -J | jq -r '.lscpu[] | select(.field=="Model name:") | .data'Model for an asset list.
9CPU flags (like AES or AVX)
Does the CPU support hardware AES?
10Compare with nproc
nproc = usable now, lscpu = present.
Nothing matches this filter.
Exit codes
0 :: Done. 1 :: Error.