Get CPU Information in Linux

superior_hosting_service

Get CPU Information In Linux

Get-CPU-Information-on-Linux.png

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:

OUTPUT:

processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 142
model name	: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
stepping	: 10
microcode	: 0x96
cpu MHz		: 700.120
cache size	: 6144 KB
physical id	: 0
siblings	: 8
core id		: 0
cpu cores	: 4
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 22
wp		: yes
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 tsc_known_freq 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 fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips	: 3600.00
clflush size	: 64
cache_alignment	: 64
address sizes	: 39 bits physical, 48 bits virtual
power management:

...

  • 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. You can find a list of all features here .

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
OUTPUT
model name	: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz

To print the number of CPUs:

$ grep -c 'model name' /proc/cpuinfo
OUTPUT
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
OUTPUT
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:  2
Core(s) per socket:  4
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               142
Model name:          Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
Stepping:            10
CPU MHz:             593.577
CPU max MHz:         3400.0000
CPU min MHz:         400.0000
BogoMIPS:            3600.00
Virtualization:      VT-x
L1d cache:           32K
L1i cache:           32K
L2 cache:            256K
L3 cache:            6144K
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 tsc_known_freq 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 fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d

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 dmidecodehardinfo and lshw, but most of them are not installed by default on Linux systems.

Feel free to leave a comment if you have any questions.