Key Fields in /proc/cpuinfo
- physical id – unique identifier for each physical processor package (socket).
- cpu cores – number of physical cores inside one package.
- processor – logical CPU identifier; every SMT sibling is counted separately.
Definitions
| Term | Meaning |
|---|---|
| Physical CPU | A real procesor chip that fits into a motherboard socket. |
| Core | An independent execution unit inside a physical CPU. |
| Logical CPU | A hardware thread exposed to the OS. With Intel Hyper-Threading, one core can provide two logical CPUs. |
Relationship:
logical_cpus = sockets × cores_per_socket × threads_per_core
If the result is larger than sockets × cores_per_socket, Hyper-Threading (or another SMT implementation) is active.
Quick Queries
# Number of sockets
awk '/physical id/ {print $4}' /proc/cpuinfo | sort -u | wc -l
# Cores per socket
awk '/cpu cores/ {print $4; exit}' /proc/cpuinfo
# Total logical CPUs
awk '/processor/ {++c} END {print c}' /proc/cpuinfo
# CPU model and count
grep -m1 'model name' /proc/cpuinfo | sed 's/.*: *//'
# Human-readable summary
lscpu
Example Output
$ lscpu
Architecture: x86_64
CPU(s): 64
Thread(s) per core: 2
Core(s) per socket: 16
Socket(s): 2
Model name: Intel(R) Xeon(R) Silver 4314 CPU @ 2.40GHz
Interpretation: two sockets, 16 cores each, 2 threads per core → 64 logical CPUs.
Per-Process Resource Usage
# Top 10 CPU consumers
ps -eo pid,ppid,cmd,%cpu --sort=-%cpu | head
# Top 10 memory consumers
ps -eo pid,ppid,cmd,%mem --sort=-%mem | head
# Top 10 virtual-memory consumers
ps -eo pid,ppid,cmd,vsz --sort=-vsz | head
Field reference:
%CPU– percentage of CPU time used since last update.%MEM– resident set size as a percentage of total RAM.VSZ– virtual memory size in KiB.STAT– process state (R running, S sleeping, D uninterruptible, Z zombie, etc.).
Sample Session
$ awk '/physical id/ {print $4}' /proc/cpuinfo | sort -u | wc -l
2
$ awk '/cpu cores/ {print $4; exit}' /proc/cpuinfo
6
$ awk '/processor/ {++c} END {print c}' /proc/cpuinfo
24
$ grep -m1 'model name' /proc/cpuinfo
model name : Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz
Result: 2 sockets, 6 cores per socket, Hyper-Threading enabled → 24 logical CPUs.