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.

More in This Category
Linux lscpu Command: Inspect CPU Architecture and Cores

Linux lscpu Command: Inspect CPU Architecture and Cores

Learn how to inspect CPU Architecture and Cores with the Linux lscpu command, including practical examples, key options, and important precautions.

Linux shred Command: Overwrite File Data and Understand Its Limits

Linux shred Command: Overwrite File Data and Understand Its Limits

Learn how Linux shred overwrites file data, which options control its passes and removal, and why SSDs, snapshots, backups, and modern filesystems limit its guarantees.

Linux umask Command: Control Default File Permissions

Linux umask Command: Control Default File Permissions

Learn how to control Default File Permissions with the Linux umask command, including practical examples, key options, and important precautions.

Linux diff Command: Compare Text Files and Directories

Linux diff Command: Compare Text Files and Directories

Learn how Linux diff compares text files and directories, produces unified patches, ignores selected whitespace changes, and reports differences through exit status.

Linux top Command: Monitor Processes in Real Time

Linux top Command: Monitor Processes in Real Time

Learn how to monitor Processes in Real Time with the Linux top command, including practical examples, key options, and important precautions.

Linux apt-get Command: Run APT Package Operations in Scripts

Linux apt-get Command: Run APT Package Operations in Scripts

Learn how to run APT Package Operations in Scripts with the Linux apt-get command, including practical examples, key options, and important precautions.

Linux rm Command: Remove Files and Directories Safely

Linux rm Command: Remove Files and Directories Safely

Learn how to remove files and directory trees with Linux rm, use interactive safeguards, limit recursive deletion, and avoid destructive path mistakes.

Linux ssh-keygen Command: Generate SSH Keys and Inspect Fingerprints

Linux ssh-keygen Command: Generate SSH Keys and Inspect Fingerprints

Learn how to generate SSH Keys and Inspect Fingerprints with the Linux ssh-keygen command, including practical examples, key options, and important precautions.

Linux nmap Command: Scan Authorized Hosts and Ports

Linux nmap Command: Scan Authorized Hosts and Ports

Learn how to scan Authorized Hosts and Ports with the Linux nmap command, including practical examples, key options, and important precautions.

Linux install Command: Copy Files and Set Attributes

Linux install Command: Copy Files and Set Attributes

Learn how to use the Linux install command to copy files while setting modes, owners, groups, timestamps, and destination directories in deployment scripts.