How to Use the lscpu Command to Check CPU Information in Linux

When you are managing a fleet of Linux servers, compiling custom software from source, or troubleshooting hardware bottlenecks, you need to know exactly what kind of processor is installed in the machine. Relying on physical server documentation is risky, as virtual machines and cloud instances obscure the underlying hardware.

To extract precise, highly detailed information about your processor architecture, cores, threads, and virtualization capabilities directly from the terminal, Linux provides the lscpu (List CPU) command.

In this guide, you will learn how to use the lscpu command and, more importantly, how to interpret the dense technical output it generates.

Running the lscpu Command

The lscpu command is a standard utility included in the util-linux package. It is available by default on almost every modern Linux distribution, including Ubuntu, Debian, CentOS, and Red Hat. It does not require root or sudo privileges to run.

Simply open your terminal and type:

lscpu

Press Enter. Your terminal will instantly populate with a structured list of CPU specifications.

How to Read the lscpu Output

The output is divided into dozens of rows. Here are the most critical lines you need to understand as a system administrator:

1. Architecture and Byte Order

  • Architecture: (e.g., x86_64 or aarch64). This tells you if the server is running a standard 64-bit Intel/AMD processor (x86_64) or an ARM-based processor (like AWS Graviton or a Raspberry Pi). This is crucial when downloading pre-compiled software binaries.
  • Byte Order: (e.g., Little Endian). This refers to how the processor stores sequences of bytes in memory.

2. CPU Cores, Threads, and Sockets

This is the most important section for understanding your server’s computing power.

  • CPU(s): This is the total number of logical processing threads available to the operating system. If this says 16, your server can handle 16 simultaneous threads.
  • Thread(s) per core: If this is 2, it means Hyper-Threading (Intel) or SMT (AMD) is enabled, allowing one physical core to act as two virtual cores.
  • Core(s) per socket: This is the number of actual physical cores inside a single CPU chip.
  • Socket(s): This indicates how many physical CPU chips are plugged into the motherboard. (Many enterprise servers have 2 or 4 sockets).

Formula: Sockets × Cores per socket × Threads per core = Total CPU(s).

3. Model and Vendor Information

  • Vendor ID: Will typically display GenuineIntel or AuthenticAMD.
  • Model name: This provides the exact marketing name of the chip, such as Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz. This is vital for checking hardware compatibility or looking up maximum thermal limits online.
  • CPU MHz / max MHz: Displays the current clock speed and the maximum boosted clock speed.

4. Virtualization and Caches

  • Virtualization: If you intend to run virtual machines (using KVM or VirtualBox), look here. It will list VT-x for Intel or AMD-V for AMD, confirming hardware virtualization is supported.
  • L1d, L1i, L2, L3 cache: Displays the size of the CPU’s internal memory caches. Larger caches drastically improve database and compiling performance.

Filtering the Output for Scripts

If you are writing a bash script and only need one specific piece of information (like the model name), parsing the entire lscpu output with grep is messy. Instead, use the -p (parse) or -J (JSON) flags, or combine it with standard text processing tools.

For example, to cleanly extract only the CPU model name, you can pipe the output into grep and awk:

lscpu | grep "Model name:" | awk -F ':' '{print $2}' | sed 's/^ *//'

By mastering the lscpu command, you can instantly audit any Linux server, ensuring you have the exact hardware resources required for your high-performance applications.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.