lscpu

system informationLinux
The lscpu command is one of the most frequently used commands in Linux/Unix-like operating systems. lscpu Display information about the CPU architecture

Quick Reference

Command Name:

lscpu

Category:

system information

Platform:

Linux

Basic Usage:

lscpu [options] [arguments]

Common Use Cases

    Syntax

    lscpu [options]

    Options

    Option Description
    -a, --all Print both online and offline CPUs
    -b, --online Print online CPUs only
    -c, --offline Print offline CPUs only
    -e, --extended[=list] Print a table of available CPUs
    -p, --parse[=list] Print in parsable format
    -s, --sysroot directory Use specified directory as system root
    -x, --hex Print CPU masks in hexadecimal format
    -y, --physical Print physical instead of logical IDs
    -C, --caches[=list] Display cache information in a table
    -J, --json Use JSON output format
    -h, --help Display help information
    -V, --version Display version information

    Examples

    How to Use These Examples

    The examples below show common ways to use the lscpu command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    lscpu
    Display information about CPU architecture.
    # Advanced Examples Advanced
    lscpu -e
    Display the list of available CPUs in a table format.
    lscpu -p Display information in a parsable format. lscpu -J Display information in JSON format. lscpu -b Display only online CPUs. lscpu -p=CPU,CORE,SOCKET,NODE Show only specified columns in parsable format. lscpu -s=ONLINE Sort the output by the ONLINE column. lscpu -c Display information in cache-hierarchy format. lscpu --hex Display CPU masks in hexadecimal format.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The 'lscpu' command is a utility that displays detailed information about the CPU architecture on Linux systems. It gathers CPU-related information from various sources like /proc/cpuinfo, sysfs, and other system-specific locations, presenting it in a unified and easily readable format. Key features of the lscpu command: 1. Comprehensive CPU Information: lscpu provides a wealth of information about the processor(s) in a system, including architecture, model name, number of cores, threads per core, cache sizes, and supported features. 2. Multiple Output Formats: The command supports various output formats, including human-readable (default), parsable format for scripts, and JSON for structured data processing. 3. NUMA Node Information: For systems with Non-Uniform Memory Access (NUMA) architecture, lscpu displays node-specific information, which is valuable for performance optimization in high-performance computing environments. 4. Cache Hierarchy Details: lscpu can show detailed information about the CPU cache hierarchy, including sizes and relationships between different cache levels. 5. CPU Topology Visualization: The command helps visualize the logical and physical topology of CPUs, cores, and threads, which is essential for understanding the system's processing capabilities. 6. Virtualization Support: lscpu indicates whether virtualization features (like VT-x for Intel or AMD-V for AMD processors) are available and enabled. 7. CPU Flag Information: It lists CPU flags that indicate supported features and extensions, such as SSE, AVX, AES, etc. Common use cases for lscpu include: - System analysis and troubleshooting - Hardware inventory and documentation - Performance tuning and optimization - Verifying virtualization capabilities before setting up virtual environments - Checking CPU features for compatibility with specific software requirements - Scripting and automation for system management lscpu is part of the util-linux package and is available on most Linux distributions by default. It's a valuable tool for system administrators, developers, and power users who need to understand the capabilities and configuration of their system's processors. The information provided by lscpu is particularly useful when dealing with modern multi-core, multi-socket systems, where understanding the CPU topology can significantly impact application performance and system configuration decisions.

    Related Commands

    These commands are frequently used alongside lscpu or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the lscpu command works in different scenarios.

    $ lscpu
    View All Commands