CPU Information

How many cores? What speed? Is the CPU maxed out? Let's find out.

lscpu - CPU Overview

Terminal
$lscpu
Architecture: x86_64 CPU(s): 4 Thread(s) per core: 2 Core(s) per socket: 2 Socket(s): 1 Model name: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz CPU MHz: 1992.000 CPU max MHz: 4000.0000

Key fields:

  • CPU(s): Total logical CPUs (cores × threads)
  • Core(s) per socket: Physical cores
  • Thread(s) per core: Hyperthreading (usually 2)
  • Socket(s): Physical CPU chips

Cores vs Threads

A 4-core CPU with hyperthreading shows as 8 CPUs. Physical cores matter most for CPU-bound work.

/proc/cpuinfo

Detailed info for each CPU:

Terminal
$cat /proc/cpuinfo | grep -E 'model name|cpu cores|processor' | head -8
processor : 0 model name : Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz cpu cores : 2 processor : 1 model name : Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz cpu cores : 2

Quick Core Count

Terminal
$nproc
4

nproc gives total available CPUs - useful in scripts.

CPU Usage

Instant Check

Terminal
$uptime
10:30:45 up 5 days, load average: 0.52, 0.48, 0.45

Load average: 1, 5, 15 minute averages.

Real-time with top

Terminal
$top -bn1 | head -5
top - 10:30:45 up 5 days, 2 users, load average: 0.52, 0.48, 0.45 Tasks: 142 total, 1 running, 141 sleeping, 0 stopped %Cpu(s): 5.2 us, 2.1 sy, 0.0 ni, 92.5 id, 0.2 wa, 0.0 hi, 0.0 si

CPU breakdown:

CodeMeaning
usUser processes
sySystem (kernel)
niNice (low priority)
idIdle
waI/O wait
hiHardware interrupts
siSoftware interrupts

High wa means CPU is waiting for slow disk.

Per-Process

Terminal
$ps aux --sort=-%cpu | head -5
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND user 1234 45.2 5.1 65432 41234 ? R 10:30 2:30 python heavy.py

mpstat - Per-Core Stats

Terminal
$mpstat -P ALL 1 1
CPU %usr %nice %sys %iowait %idle all 5.12 0.00 2.13 0.25 92.50 0 8.00 0.00 3.00 0.50 88.50 1 3.00 0.00 1.50 0.00 95.50 2 4.50 0.00 2.00 0.25 93.25 3 5.00 0.00 2.00 0.25 92.75

This shows if one core is maxed while others are idle (single-threaded bottleneck).

Knowledge Check

A server shows 4 CPUs with lscpu. The load average is 2.0. Is this concerning?

Quick Reference

CommandShows
lscpuCPU specifications
nprocNumber of CPUs
/proc/cpuinfoDetailed CPU info
uptimeLoad averages
top then 1Per-core usage
mpstat -P ALLPer-core statistics

Key Takeaways

  • lscpu shows CPU specifications
  • nproc gives CPU count for scripts
  • Load average should be compared to core count
  • High wa (I/O wait) indicates disk bottleneck
  • Use top with 1 key to see per-core usage

Next: reading system logs.