Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท System Information

Linux lscpu command

Reference for the Linux lscpu command: list architecture, cores, threads, caches and flags, get parseable output with -e and -J, and read /proc/cpuinfo.

lscpu gathers CPU facts from the kernel (/proc/cpuinfo, /sys/devices/system/cpu) and prints them in a readable table: architecture, number of logical CPUs, threads per core, cores per socket, model name, clock speeds, cache sizes and feature flags.

Use it to answer "how many cores does this machine have?", "is this 64-bit?" or "does the CPU support AVX2 or hardware virtualization?". It is part of the util-linux package.

Terminal
lscpu [OPTION]...

Try it

Bash lscpu needs /sys (it fails in a sandbox)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Check for CPU features in /proc/cpuinfo

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
lscpu [-a | -b | -c] [-e[=LIST] | -p[=LIST]] [-J] [-x] [-C] [-y]
Option Description
-e[=LIST], --extended One row per logical CPU (columns such as CPU, CORE, SOCKET, ONLINE, MAXMHZ).
-p[=LIST], --parse Comma-separated rows, easy to parse.
-J, --json Output as JSON (recent util-linux).
-a, --all Include offline CPUs.
-b, --online Only online CPUs (with -e/-p).
-C, --caches Show cache details.
-x, --hex Print CPU masks in hexadecimal.

Key fields in the default output:

Field Meaning
Architecture Instruction set, e.g. x86_64 or aarch64.
CPU(s) Number of logical CPUs (hardware threads).
Thread(s) per core 2 when simultaneous multithreading (hyper-threading) is on.
Core(s) per socket, Socket(s) Physical layout.
Model name, CPU MHz Marketing name and clock.
L1d, L2, L3 Cache sizes.
Flags Feature list: sse4_2, avx2, vmx or svm (virtualization), lm (64-bit).
Hypervisor vendor Present when running inside a virtual machine.

Returns: 0 on success; non-zero if the system information cannot be read.

Usage notes

  • CPU(s) counts logical CPUs. Physical cores = Core(s) per socket times Socket(s). For "how many tasks can run at once", nproc is what you want.
  • Virtual machines and containers: numbers show what the hypervisor gives the guest. In a container with CPU limits, lscpu still shows the host CPUs while nproc respects affinity (cgroup quotas are different again).
  • Fields vary by architecture. ARM machines have no Flags line but Features; some virtual CPUs have no cache sizes. Scripts must tolerate missing keys.
  • Parse with -J or -p, not by cutting columns from the default view, whose spacing changes between versions.
  • Hardware virtualization: grep -Eo 'vmx|svm' /proc/cpuinfo | sort -u tells you if Intel VT-x or AMD-V is exposed.
  • Raw source: /proc/cpuinfo has one stanza per logical CPU; lscpu summarizes it. See /proc/cpuinfo.
  • Runtime frequency changes constantly; the CPU MHz value is a snapshot.