Posted: . At: 10:35 AM. This was 4 years ago. Post ID: 14372
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to easily get information about your CPU on Linux.


Getting information about your CPU on Linux is very easy. There are many ways to do this.

The cpufreq app is one good way to get the current CPU frequency.

4.4 Thu Jun 04 jason@Yog-Sothoth 0: $ cpufreq-info -f -m
988 MHz

This command above shows the current CPU frequency in human-readable values.

To print information about all of your cores in your CPU, use this syntax.

4.4 Thu Jun 04 jason@Yog-Sothoth 0: $ cpufreq-info -o -m
          minimum CPU frequency  -  maximum CPU frequency  -  governor
CPU  0       800000 kHz ( 21 %)  -    3800000 kHz (100 %)  -  powersave
CPU  1       800000 kHz ( 21 %)  -    3800000 kHz (100 %)  -  powersave
CPU  2       800000 kHz ( 21 %)  -    3800000 kHz (100 %)  -  powersave
CPU  3       800000 kHz ( 21 %)  -    3800000 kHz (100 %)  -  powersave

This shows the maximum and minimum frequencies for all of your CPU cores. As well as the cpufreq governor(s) applied to the CPU. Yet another way to quickly get CPU information is the lscpu command. This prints comprehensive information about your CPU and is very useful for getting quick system information.

4.4 Thu Jun 04 jason@Yog-Sothoth 0: $ lscpu 
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              4
On-line CPU(s) list: 0-3
Thread(s) per core:  1
Core(s) per socket:  4
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               60
Model name:          Intel(R) Core(TM) i5-4670K CPU @ 3.40GHz
Stepping:            3
CPU MHz:             2351.528
CPU max MHz:         3800.0000
CPU min MHz:         800.0000
BogoMIPS:            6797.68
Virtualisation:      VT-x
L1d cache:           32K
L1i cache:           32K
L2 cache:            256K
L3 cache:            6144K
NUMA node0 CPU(s):   0-3
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 arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d

Another way to print the speed of all CPU cores with grep and awk.

4.4 Thu Jun 04 jason@Yog-Sothoth 0: $ grep "MHz" /proc/cpuinfo | awk '{ print $4 }'
2035.001
2240.924
2125.596
2096.706

This is an even better way, this prints the CPU frequency of each core and numbers each line.

4.4 Thu Jun 04 jason@Yog-Sothoth 0: $ grep "MHz" /proc/cpuinfo | awk '{printf("CPU Core %4d: %s\n", NR,$4) }'
CPU Core    1: 2337.012
CPU Core    2: 2176.983
CPU Core    3: 2235.132
CPU Core    4: 2223.365

This is using the printf function in awk to manipulate the text and then print nice output. This is how easy it is to get a simple CPU frequency output with Linux.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.