Linux lscpu Command: Inspect CPU Architecture and Cores
lscpu shows the CPU architecture recognized by Linux, the number of logical CPUs, core/socket configuration, and cache information. It serves as a starting point when assessing server capacity and virtualization environments.
What is the lscpu command?
The information is mainly gathered from sysfs and /proc/cpuinfo. The CPU(s) refers to the number of logical CPUs seen by the operating system and may not be the same as the number of physical cores. In virtual machines, the configuration is usually the one provided to the guest, so it should be distinguished from the host hardware specifications.
Basic syntax
lscpu [option]
The installed implementation and options may vary depending on the distribution. Check the current system's description with man lscpu.
Examples
Viewing CPU Overview
Check the architecture, logical CPUs, sockets, and cores together.
lscpu
Viewing CPU List
Displays columns per CPU, such as online status, in a table format.
lscpu -e
View cache information
Check the cache hierarchy and size summary.
lscpu -C
Distinguishing Logical CPUs and Physical Cores
lscpu summarizes the CPU architecture recognized by the kernel, the number of logical CPUs, and the socket, core, and thread configuration.
lscpu | head -n 8
Part of an example output (item names and values may vary depending on the environment):
Architecture: x86_64 CPU(s): 8 Thread(s) per core: 2 Core(s) per socket: 4
In the above example, 8 logical CPUs correspond to 4 physical cores with 2 threads each. In virtual machines and containers, you may see the allocated or exposed values rather than the host's full physical CPUs. To check actual usage, use top or other monitoring tools together.
Main Options and Format
| Options/Format | Description |
|---|---|
-e |
Display detailed information by CPU. |
-p |
Display in an easy-to-parse format. |
-C |
Display cache information. |
-a |
Includes online/offline CPUs. Use with -e or -p. |
-J |
Show in JSON format on supported versions. |
Precautions when using
The CPU configuration seen in containers or virtual machines may differ from the allocation or actual host resources. The default output fields and sort order may change depending on the util-linux version, so explicitly select columns in scripts. Do not judge performance based solely on the number of CPUs.
Frequently Asked Questions
Are the CPU(s) in lscpu the number of physical cores?
No. They are the number of logical CPUs visible to the operating system. You need to read the cores, sockets, and threads fields together.
Official Documentation
You can check the exact behavior of the options and implementation differences in the official lscpu documentation.









