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.
lscpu [OPTION]...
Try it
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.
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
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 sockettimesSocket(s). For "how many tasks can run at once",nprocis what you want. - Virtual machines and containers: numbers show what the hypervisor gives the guest. In a container with CPU limits,
lscpustill shows the host CPUs whilenprocrespects affinity (cgroup quotas are different again). - Fields vary by architecture. ARM machines have no
Flagsline butFeatures; some virtual CPUs have no cache sizes. Scripts must tolerate missing keys. - Parse with
-Jor-p, not by cutting columns from the default view, whose spacing changes between versions. - Hardware virtualization:
grep -Eo 'vmx|svm' /proc/cpuinfo | sort -utells you if Intel VT-x or AMD-V is exposed. - Raw source:
/proc/cpuinfohas one stanza per logical CPU;lscpusummarizes it. See /proc/cpuinfo. - Runtime frequency changes constantly; the
CPU MHzvalue is a snapshot.
Related
nproc, /proc/cpuinfo,lspciandlsusb,uname- Lessons: Performance and tricks, Processes