lscpu
Display CPU architecture information
TLDR
Display information about all CPUs
Display information in a table
Display only information about online CPUs in a table
Display only information about offline CPUs in a table
Display details about CPU caches
Display information in JSON format
SYNOPSIS
lscpu [options]
PARAMETERS
-a, --all
Show all CPUs, including offline ones. By default, only online CPUs are shown.
-b, --online
Only show online CPUs. This is the default behavior and is useful for explicitly ensuring offline CPUs are excluded.
-c, --caches
Display CPU cache information, including L1d, L1i, L2, and L3 cache sizes and types.
-e, --extended
Show extended, columnar output. This provides a more detailed, tabular view of CPU, Core, Socket, and NUMA node relationships.
-J, --json
Output the CPU information in JSON format, suitable for machine parsing and integration into scripts or applications.
-p, --parse
Optimize the output for easy parsing by scripts, presenting information in a colon-separated key=value pair format.
-S, --sysroot directory
Gather CPU information from a specified alternative system root directory instead of the live system.
-V, --version
Display the version information for the lscpu command and exit.
-h, --help
Display a brief help message explaining the command's usage and available options, then exit.
DESCRIPTION
lscpu is a command-line utility that gathers and displays comprehensive information about the CPU(s) on a Linux system. It provides a human-readable output summarizing the system's CPU architecture, including the number of CPUs, cores, sockets, threads, NUMA nodes, CPU family, model, vendor ID, cache sizes, and various CPU flags (capabilities).
The data is primarily sourced from /proc/cpuinfo and the sysfs filesystem (specifically /sys/devices/system/cpu/). This command is invaluable for system administrators, developers, and users who need quick access to detailed hardware specifications for troubleshooting, performance tuning, or understanding system capabilities. Unlike parsing /proc/cpuinfo directly, lscpu presents the information in a structured and easy-to-understand format, making it a preferred tool for CPU introspection.
CAVEATS
The information provided by lscpu is derived from the kernel's view of the CPU topology and features. While generally accurate, inconsistencies can arise if the kernel or underlying hardware abstraction layer has issues. It relies heavily on the format of /proc/cpuinfo and sysfs, which may have minor variations across different kernel versions or architectures.
DATA SOURCE
lscpu primarily extracts its information from /proc/cpuinfo, which is a virtual file system entry containing details about the CPU, and the sysfs filesystem, specifically the /sys/devices/system/cpu/ directory. These kernel-provided interfaces offer real-time details about the CPU's topology and features, allowing lscpu to present an up-to-date view of the hardware.
OUTPUT FLEXIBILITY
Beyond its default human-readable format, lscpu offers flexible output options like JSON (-J) and a parse-friendly key-value pair format (-p). This makes it highly suitable for scripting, automated data collection, and integration into monitoring or inventory management systems, allowing programmatic access to detailed CPU specifications.
HISTORY
lscpu is part of the util-linux project, a collection of essential Linux system utilities. It was developed to provide a more structured, consistent, and user-friendly way to display CPU information compared to directly parsing the varying formats of /proc/cpuinfo across different architectures and kernel versions. Its development aimed at standardizing CPU reporting for system introspection and management.