Introduction
A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program.
The CPU performs basic arithmetic, logic, controlling, and input/output (I/O) operations specified by the instructions in the program.
This contrasts with external components such as main memory and I/O circuitry, and specialized processors such as graphics processing units (GPUs).
CPU is considered as the brain of a Computer. You may want to know the basic details of your processor, processor speed, architecture, number of cores and cache size.
In this article, we will discuss some methods to find CPU information in Linux using command line tools.
NOTE: All methods below are tested in RHEL 8 systems.
Using lscpu
list cpu belongs to a group of command-line commands, all with “ls” start (eg lspci, lsusb, lspcmcia), and information on specific hardware components provide. As the name suggests, in this case the processor.
The command is particularly useful for two use cases:
- Is the CPU suitable for a 64-bit operating system
- Number of cores in the processor
- Find CPU information in Linux using lscpu command, just run:
lscpu
![](http://unixcop.com/wp-content/uploads/2022/01/image-66-1024x427.png)
- You can filter your previous results using grep command with a specific detail such as:
lscpu | grep -i 'Model'
![](http://unixcop.com/wp-content/uploads/2022/01/image-67.png)
- To find the number of CPU cores, run:
lscpu | grep -i "CPU(s)"
![](http://unixcop.com/wp-content/uploads/2022/01/image-68.png)
Using /proc/cpuinfo file
- You can find the CPU info by displaying the contents of /proc/cpuinfo file as follows:
cat /proc/cpuinfo
![](http://unixcop.com/wp-content/uploads/2022/01/image-69-1024x478.png)
Using dmidecode
dmidecode is a free user space command-line utility for Linux that can parse the SMBIOS data details of a system’s hardware components from DMI (Desktop Management Interface) table.
After locating the DMI table, dmidecode will display system’s hardware information in a human-readable format.
- To display the CPU details with dmidecode
sudo dmidecode --type processor
![](http://unixcop.com/wp-content/uploads/2022/01/image-72.png)
Using lshw
lshw (Hardware Lister) is a small tool to provide detailed information on the hardware configuration of the machine. It can report exact memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed, etc.
- Use lshw to get just CPU info:
sudo lshw -class processor
![](http://unixcop.com/wp-content/uploads/2022/01/image-70-1024x291.png)
- Use -short option to display only the processor model as shown below
sudo lshw -short -class processor
![](http://unixcop.com/wp-content/uploads/2022/01/image-71.png)
Using inxi
inxi is a command line system information tool to display system information such as CPU, drivers, xorg, desktop environment, Kernel, GCC version(s), RAM usage…etc
- You can install it with running the below command line:
sudo dnf install inxi #centos,RHEL
sudo apt install inxi #Ubuntu
- To display Processor info using inxi use -C option or –cpu flag:
inxi -C
inxi --cpu
![](http://unixcop.com/wp-content/uploads/2022/01/image-73.png)
As shown above, it displayed number of cores, CPU cache, CPU model, Core Speeds, CPU clock speed, CPU min and max speed.
Using cpuid
Cpuid command views an information about the CPU(s) gathered from the CPUID instruction, and also displays the exact model of CPU(s) from that information.
- To install this utility:
sudo dnf install cpuid #centos,RHEL
sudo apt install cpuid #Ubuntu
- To get the CPU info using cpuid command
cpuid
![](http://unixcop.com/wp-content/uploads/2022/01/image-76.png)
Using hwinfo
hwinfo (Hardware information) is a command line utility to find a system’s hardware information. It displays the extensive details of each hardware device.
- To install it
sudo dnf install hwinfo #centos,RHEL
sudo apt install hwinfo #Ubuntu
- Display CPU information with hwinfo using –cpu flag:
sudo hwinfo --cpu
![](http://unixcop.com/wp-content/uploads/2022/01/image-74-1024x473.png)
- To summarize the latest output for hwinfo, use the –short flag as shown below
sudo hwinfo --short --cpu
![](http://unixcop.com/wp-content/uploads/2022/01/image-75.png)
Additional tools
- You can get CPU info using nproc tool which is part of GNU core-utils. It doesn’t provide much information on CPU. It only prints the number of processing units available to the current process as shown below.
nproc
OR
nproc --all
![](http://unixcop.com/wp-content/uploads/2022/01/image-77.png)
- If you want to find what architecture the processors are using such as broadwell, Sandybridge and Ivybridge, run:
cat /sys/devices/cpu/caps/pmu_name
![](http://unixcop.com/wp-content/uploads/2022/01/image-79.png)
NOTE: This fie doesn’t available for machines with AMD processor.
Conclusion
That’s it,
In this guide, we have illustrated how to check and find the information of CPU in Linux through command line with about 7 methods in addition to some features for each one.
Thanks