Linux Command Reference ยท Special Files and Directories
The /proc/cpuinfo file
Reference for /proc/cpuinfo: how the per-processor blocks are laid out, key fields such as model name and flags, counting cores, and checking CPU features.
/proc/cpuinfo is a virtual file generated by the kernel. Reading it prints one block of key : value lines for each logical processor, separated by a blank line. It tells you the CPU model, its speed, cache size, and the feature flags (such as sse4_2, avx2, aes or vmx) that decide what instructions programs can use.
Nothing is stored on disk; each read asks the kernel for fresh data. The exact fields depend on the architecture: x86 has model name and flags; ARM uses Features and CPU part. Tools like lscpu and nproc read this and /sys and present it more tidily.
grep -c '^processor' /proc/cpuinfo grep -m1 'model name' /proc/cpuinfo
Try it
Values depend on the machine running the example, so these examples print facts that hold anywhere.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
Common x86 fields:
| Field | Description |
|---|---|
processor |
Logical CPU number, starting at 0. A hyper-threaded core counts as two. |
vendor_id, model name |
Manufacturer and marketing name. |
cpu MHz |
Current clock speed; it changes with power management. |
cache size |
Size of the last-level cache seen by this CPU. |
physical id, core id, siblings, cpu cores |
Topology: package (socket), core in package, and counts. |
flags |
Space-separated feature list. |
bogomips |
A crude timing value, not a benchmark. |
address sizes |
Physical and virtual address bits. |
Edge cases: field separators contain tabs before the colon, so match with a pattern like ^model name rather than a fixed-width cut. On virtual machines and containers some fields (physical id, core id) may be missing or misleading. On ARM there is no model name; read lscpu instead.
Usage notes
- Counting:
nprochonors CPU affinity and cgroup limits (what your process may use), whilegrep -c ^processorcounts all CPUs the kernel sees. In containers they can differ; usenproc --allfor the total. - Hyper-threading: logical CPUs equal physical cores times threads per core. Compare
siblingsandcpu cores. - Flags show hardware capability, not what the OS enables.
vmxorsvmmeans virtualization support;lmmeans 64-bit;aesallows hardware encryption. - Frequency changes on every read; do not compare it to the label in
model name. - Only
cat-able. You cannot write to it; tuning goes through/sys/devices/system/cpu/. See/sys. - Security fields: newer kernels add
bugsandvmx flags, listing known CPU vulnerabilities and virtualization details. - Performance: reading it is cheap, but on machines with hundreds of CPUs the output is large; filter early.
Related
/proc/meminfo,/proc/loadavg,/proc/PID,/sys- Lessons: Processes, Performance and Tricks