Oct 8, 2023 5 min read

Get CPU Information on Linux

Get CPU information on Linux with our step-by-step tutorial. CPU information is commonly referred to as the computer's brain.

CPU Information on Linux
Table of Contents

Introduction

Before we discuss Get CPU information on Linux, let's understand-What is a CPU ?

One of the most important components of your computer is the CPU (central processing unit), sometimes known as the processor. It is commonly referred to as the computer's brain because it executes all types of data processing activities.

Getting CPU information on Linux allows you to retrieve details about the processor(s) installed in your system. This information includes the CPU model, architecture, number of cores, clock speed, cache size, and more. Understanding CPU information

In this tutorial, we will talk about the steps to get CPU information on Linux. We will also address a few FAQs to Get CPU Information on Linux.

Get CPU Info in Linux

Displaying the contents of the /proc/cpuinfo virtual file is the simplest approach to figure out what type of CPU you have.

It is not necessary to install any additional programs to determine the kind of processor using the proc/cpuinfo file. It will work regardless of the Linux distribution you use.

To view the contents of /proc/cpuinfo, open your terminal and type less or cat:

less /proc/cpuinfo

The command will print an identification number for each logical CPU. If you have an 8-core processor, for example, you will see a list of all cores numbered from 0 to 7. An example of the output is shown below:

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:

...

The most interesting lines are explained below:

  • processor - Each processor's unique identifier number, starting at 0.
  • model name - The processor's complete name, including the manufacturer. You can review the product documentation for your processor's specifications once you know what type of CPU you have.
  • flags - CPU features, a complete list of features may be found here.

The grep command can be used to filter the output. To display only the processor name, for example, type:

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

When you need to assemble software from the source code and want to know how many parallel processes can run at the same time, knowing the number of CPUs is useful. The nproc command can also be used to determine the number of CPUs:

nproc
Output

8

Check CPU Info with lscpu

lscpu is a command-line utility that shows CPU architectural information. All Linux distributions include the util-linux package, which includes lscpu.

Type lscpu at a shell prompt.

lscpu

The result will look like this, including details on the number of CPUs, architecture, vendor, family, model, speed, caches, and flags, among other things.

Output

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

The output of the lscpu command, unlike the content of the /proc/cpuinfo file, does not provide a list of all logical CPUs.

FAQs to Get CPU Information on Linux

How can I get CPU information on Linux?

There are multiple ways to get CPU information on Linux. Common commands include lscpu, cat /proc/cpuinfo, and utilities like dmidecode and hwinfo.

What does the lscpu command display?

The lscpu command provides detailed CPU information, such as the CPU model, architecture, vendor, CPU MHz, number of sockets, cores, threads, cache sizes, and more.

How do I use the lscpu command?

Open a terminal and simply type lscpu. The command will display the CPU information specific to your system.

What information is available in /proc/cpuinfo?

The /proc/cpuinfo file contains detailed information about each CPU installed in the system, including processor type, model name, cache sizes, flags, and more.

How can I view the contents of /proc/cpuinfo?

To view the contents of /proc/cpuinfo, use the cat command followed by the file's path. For example, cat /proc/cpuinfo will display the CPU information in the terminal.

What is the difference between CPU cores and threads?

CPU cores are physical processing units that execute instructions, while threads represent separate execution contexts within a core. A CPU core can have multiple threads, allowing for concurrent execution of instructions.

How can I determine the number of CPU cores?

The number of CPU cores can be determined using the lscpu command or by checking the cpu cores field in the output of /proc/cpuinfo.

Conclusion

We've taught you how to get information about your system's CPU in this tutorial. Other programs, such as dmidecode, hardinfo, and lshw, can be used to establish your CPU name and vendor, but most of these are not installed by default on Linux systems.

If you have any queries, please leave a comment below and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.