How To Get Cpu Info In Linux : Using Command Line Tools Guide

Your Linux terminal holds a surprising amount of hardware information, and finding your CPU details is simpler than you might think. If you’ve ever wondered how to get cpu info in linux, you’re in the right place. This guide will walk you through every method, from simple commands to deep system queries, so you can master your machine’s processor details.

Whether you’re a system admin, a developer, or just curious about your hardware, knowing your CPU specs helps with troubleshooting, performance tuning, and compatibility checks. Let’s jump right in with the most common and powerful tools.

How To Get Cpu Info In Linux

The quickest way to get a full CPU report is using the /proc/cpuinfo virtual file. This file is generated by the kernel and contains detailed information about each processor core. Open your terminal and type:

cat /proc/cpuinfo

This command prints a long list of data. You’ll see entries for each core, including the model name, vendor, cache size, and flags. It’s the most comprehensive single source for CPU info.

To make it easier to read, you can pipe the output to less or more:

cat /proc/cpuinfo | less

This lets you scroll through the data page by page. Press q to exit.

Using Lscpu For A Clean Summary

The lscpu command is part of the util-linux package and gives a nicely formatted summary. It’s pre-installed on most distributions. Just type:

lscpu

You’ll see output like this:

  • Architecture: x86_64
  • CPU op-mode(s): 32-bit, 64-bit
  • Byte Order: Little Endian
  • CPU(s): 8
  • On-line CPU(s) list: 0-7
  • Thread(s) per core: 2
  • Core(s) per socket: 4
  • Socket(s): 1
  • NUMA node(s): 1
  • Vendor ID: GenuineIntel
  • CPU family: 6
  • Model: 158
  • Model name: Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
  • Stepping: 9
  • CPU MHz: 4200.000
  • CPU max MHz: 4200.0000
  • CPU min MHz: 800.0000
  • BogoMIPS: 8400.00
  • Virtualization: VT-x
  • L1d cache: 32K
  • L1i cache: 32K
  • L2 cache: 256K
  • L3 cache: 8192K
  • NUMA node0 CPU(s): 0-7
  • Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves arat umip md_clear flush_l1d arch_capabilities

This is perfect for a quick overview. The lscpu command also works on ARM and other architectures.

Checking CPU Info With Dmidecode

For detailed hardware information from the system BIOS, use dmidecode. This tool reads the DMI (Desktop Management Interface) table. You’ll need root privileges:

sudo dmidecode -t processor

This shows data like the processor version, socket type, and maximum speed. It’s useful for identifying the exact model when /proc/cpuinfo isn’t enough.

Using Inxi For A Human-Readable Report

inxi is a powerful system information tool that gives a clean, colored output. Install it if you don’t have it:

sudo apt install inxi   # Debian/Ubuntu
sudo dnf install inxi   # Fedora

Then run:

inxi -C

You’ll get a concise CPU summary with core count, speed, and cache details. For even more detail, use inxi -F for a full system report.

Getting Real-Time CPU Usage And Info

Sometimes you need to monitor CPU performance live. The top command shows real-time process usage, but you can also get a quick CPU summary with htop (install it first). For a simple one-liner, try:

lscpu | grep -E "Model name|CPU MHz|CPU max MHz"

This filters only the most relevant lines. You can also use nproc to get the number of processing units:

nproc

This returns just a number, like 8, which is handy for scripting.

Using /Proc/Cpuinfo In Depth

The /proc/cpuinfo file is the backbone of CPU info in Linux. Each processor core has a block of data. Here’s what the key fields mean:

  • processor: Logical core number (starts at 0)
  • vendor_id: CPU manufacturer (GenuineIntel, AuthenticAMD, etc.)
  • cpu family: Family number (e.g., 6 for modern Intel)
  • model: Model number
  • model name: Full CPU name
  • stepping: Revision level
  • cpu MHz: Current frequency
  • cache size: L2 cache per core
  • physical id: Socket ID
  • core id: Physical core ID
  • cpu cores: Number of physical cores per socket
  • siblings: Number of threads per socket
  • flags: CPU features (like aes, avx, sse)

To count total cores, use:

grep -c ^processor /proc/cpuinfo

This returns the number of logical cores. For physical cores, use:

grep "core id" /proc/cpuinfo | sort -u | wc -l

Extracting Specific Info With Grep

You can combine grep with /proc/cpuinfo to get just what you need. For example, to see only the model name:

grep "model name" /proc/cpuinfo | uniq

To get the CPU vendor:

grep "vendor_id" /proc/cpuinfo | uniq

For cache size:

grep "cache size" /proc/cpuinfo | uniq

This approach is fast and works on any Linux system.

Using Lscpu For Scripting And Automation

lscpu is great for scripts because its output is easy to parse. You can use the --parse option to get machine-readable output:

lscpu --parse

This prints comma-separated values for each core. For a specific field, use --extended:

lscpu --extended

You can also use lscpu with grep to get one value:

lscpu | grep "Model name" | awk -F: '{print $2}'

This extracts just the model name string.

Checking CPU Architecture

To see if your system is 32-bit or 64-bit, use:

lscpu | grep "Architecture"

Or use the arch command:

arch

This returns something like x86_64 or aarch64.

Using Dmidecode For BIOS-Level Details

dmidecode gives you information from the system’s DMI table, which is stored in the BIOS. This includes the processor socket type, maximum supported speed, and even the manufacturer’s part number. Run:

sudo dmidecode -t processor | less

Look for fields like:

  • Socket Designation: The physical socket (e.g., LGA1151)
  • Type: Central Processor
  • Family: Core i7
  • Manufacturer: Intel
  • ID: A hex string
  • Version: Full model name
  • Voltage: Operating voltage
  • External Clock: Base clock speed
  • Max Speed: Maximum supported speed
  • Current Speed: Current operating speed
  • Status: Populated, Enabled
  • Upgrade: Socket type
  • L1 Cache Handle, L2 Cache Handle, L3 Cache Handle: Links to cache info

This is especially useful for hardware upgrades or compatibility checks.

Getting Cache Information

You can get detailed cache info from /sys/devices/system/cpu/cpu0/cache/. For example:

cat /sys/devices/system/cpu/cpu0/cache/index0/size

This returns the L1 data cache size. Index0 is L1d, index1 is L1i, index2 is L2, and index3 is L3. You can script this to get all cache sizes.

Alternatively, use lscpu which already shows cache sizes in a clean format.

Using Htop And Top For Live CPU Monitoring

While not strictly for static info, htop and top show real-time CPU usage per core. Install htop with your package manager:

sudo apt install htop

Then run:

htop

At the top, you’ll see a bar graph for each core, along with load averages and uptime. Press F2 to customize the display. This is great for seeing how your CPU handles tasks.

Using Cpuid For Low-Level Details

The cpuid tool reads the CPUID instruction directly from the processor. Install it:

sudo apt install cpuid

Then run:

cpuid

This gives extremely detailed information, including feature flags, cache topology, and thermal monitoring capabilities. It’s more technical but invaluable for kernel developers and overclockers.

Using Neofetch For A Fun System Summary

neofetch is a popular tool that displays system info with an ASCII logo. Install it:

sudo apt install neofetch

Then run:

neofetch

You’ll see your CPU model, cores, speed, and cache alongside other system details. It’s not the most detailed, but it’s visually appealing and great for screenshots.

Using Hardinfo For A GUI Experience

If you prefer a graphical interface, install hardinfo:

sudo apt install hardinfo

Then run:

hardinfo

This opens a window with a tree view of all hardware, including CPU details. You can also generate a report from the command line:

hardinfo -r > report.html

This creates an HTML report you can open in a browser.

Checking CPU Temperature And Frequency

To monitor CPU temperature, use sensors from the lm-sensors package:

sudo apt install lm-sensors
sudo sensors-detect
sensors

For frequency scaling, check /sys/devices/system/cpu/cpu0/cpufreq/:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

This shows the current frequency in kHz. You can also use cpufreq-info from the cpufrequtils package:

cpufreq-info

This lists all cores and their frequency ranges.

Using Tlp For Power And CPU Stats

tlp is a power management tool that also shows CPU info. Install it:

sudo apt install tlp
sudo tlp stat

This gives a comprehensive report including CPU frequency, temperature, and power consumption.

Scripting A Custom CPU Info Report

You can create a simple bash script to show the most important CPU details. Here’s an example:

#!/bin/bash
echo "=== CPU Information ==="
echo "Model: $(grep 'model name' /proc/cpuinfo | uniq | awk -F: '{print $2}')"
echo "Cores: $(nproc)"
echo "Architecture: $(uname -m)"
echo "Max Speed: $(lscpu | grep 'CPU max MHz' | awk -F: '{print $2}') MHz"
echo "Cache: $(lscpu | grep 'L3 cache' | awk -F: '{print $2}')"

Save it as cpuinfo.sh, make it executable with chmod +x cpuinfo.sh, and run it. This gives you a quick, custom report.

Using Python For Cross-Platform Info

If you prefer Python, the platform module works on Linux:

python3 -c "import platform; print(platform.processor())"

For more detail, use psutil:

pip install psutil
python3 -c "import psutil; print(psutil.c