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 tar Command: Create and Extract Archives

Linux tar Command: Create and Extract Archives

Learn how to create and Extract Archives with the Linux tar command, including practical examples, key options, and important precautions.

Linux tracepath Command: Trace a Network Path and Path MTU

Linux tracepath Command: Trace a Network Path and Path MTU

Learn how to trace a Network Path and Path MTU with the Linux tracepath command, including practical examples, key options, and important precautions.

Linux jobs Command: List Jobs in the Current Shell

Linux jobs Command: List Jobs in the Current Shell

Learn how to list Jobs in the Current Shell with the Linux jobs 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 gunzip Command: Decompress gzip Files

Linux gunzip Command: Decompress gzip Files

Learn how to decompress gzip Files with the Linux gunzip command, including practical examples, key options, and important precautions.

Linux unalias Command: Remove Command Aliases

Linux unalias Command: Remove Command Aliases

Learn how to use the Linux unalias command to remove one or all aliases from the current shell session, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux ethtool Command: Inspect Network Link and Driver Settings

Linux ethtool Command: Inspect Network Link and Driver Settings

Learn how to inspect Network Link and Driver Settings with the Linux ethtool 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 ip Command: Inspect and Configure Network Interfaces and Routes

Linux ip Command: Inspect and Configure Network Interfaces and Routes

Learn how to inspect and Configure Network Interfaces and Routes with the Linux ip command, including practical examples, key options, and important precautions.

Linux comm Command: Compare Two Sorted Files

Linux comm Command: Compare Two Sorted Files

Learn how to compare Two Sorted Files with the Linux comm command, including practical examples, key options, and important precautions.