How to get CPU information.

How To Get CPU Information.

The CPU (central processing unit), often called simply processor, is one of the essential components of your computer. It performs all types of data processing operations, and it often referred to as the computer’s brain.

Have you ever wondered what type of CPU you have in your system and what is the CPU speed? There are various reasons why you might need to know what CPU you have inside your machine. Perhaps you’re loading a kernel module or debugging a hardware related issue. Whatever the reason, on Linux, it’s quite easy to determine the processor type and speed from the command line.

 

Get CPU Info in Linux

The simplest way to determine what type of CPU you have is by displaying the contents of the /proc/cpuinfo virtual file.

Identifying the type of processor using the proc/cpuinfo file does not require installing any additional programs. It will work no matter what Linux distribution you are using.

Open your terminal and use less or cat to display the contents of /proc/cpuinfo:

less /proc/cpuinfo

The command will print each logical CPU with an identifying number. For example, if you have 8 core processor you will see a list of all cores starting from 0 to 7. Below is an example of the output:

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 13
model name      : QEMU Virtual CPU version 2.5+
stepping        : 3
microcode       : 0x1
cpu MHz         : 2394.454
cache size      : 16384 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm rep_good nopl xtopology eagerfpu pni cx16 x2apic hypervisor lahf_lm rsb_ctxsw
bogomips        : 4788.90
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 13
model name      : QEMU Virtual CPU version 2.5+
stepping        : 3
microcode       : 0x1
cpu MHz         : 2394.454
cache size      : 16384 KB
physical id     : 1
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm rep_good nopl xtopology eagerfpu pni cx16 x2apic hypervisor lahf_lm rsb_ctxsw
bogomips        : 4788.90
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

processor       : 2
vendor_id       : GenuineIntel
cpu family      : 6
model           : 13
model name      : QEMU Virtual CPU version 2.5+
stepping        : 3
microcode       : 0x1
cpu MHz         : 2394.454
cache size      : 16384 KB
physical id     : 2

Below is an explanation of the most interesting lines:

  • processor – A unique identifying number of each processor, starting from 0.

  • model name – The full name of the processor, including the processor brand. Once you know the exact type of CPU you are having, you can check the product documentation about your processor’s specifications.

  • flags – CPU features.

If you want to filter the output you can use the grep command . For example, to display only the processor name you would use:

grep -m 1 'model name' /proc/cpuinfo
model name	: QEMU Virtual CPU version 2.5+

To print the number of CPUs:

grep -c 'model name' /proc/cpuinfo
8

Knowing the number of CPUs can be handy when you need to compile software from the source, and you want to know how many parallel processes can be concurrently executed. Another way to find the number of CPUs is by using the nproc command:

nproc
8

 

Check CPU Info with lscpu

lscpu is a command-line utility that displays information about the CPU architecture. lscpu is a part of the util-linux package which is installed on all Linux distributions.

At a shell prompt, type lscpu:

lscpu

The output will look something like below, including information about the number of CPUs, architecture, vendor, family, model, speed, caches, flags, etc.

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:    1
Core(s) per socket:    1
Socket(s):             8
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 13
Model name:            QEMU Virtual CPU version 2.5+
Stepping:              3
CPU MHz:               2394.454
BogoMIPS:              4788.90
Hypervisor vendor:     KVM
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              4096K
L3 cache:              16384K
NUMA node0 CPU(s):     0-7
Flags:                 fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm rep_good nopl xtopology eagerfpu pni cx16 x2apic hypervisor lahf_lm rsb_ctxsw

Unlike the content of the /proc/cpuinfo file, the output of the lscpu doesn’t show a list of all logical CPUs.

 

Conclusion

In this guide, we have shown you how to find information about your system CPU. There are also other tools that you can use to determine your CPU name and vendor such as dmidecode, hardinfo and lshw, but most of them are not installed by default on Linux systems.