MQ-Jr
MQ-Jr
unixcop Admin

How To Find CPU Information In Linux Using Command Line

Introduction

central processing unit (CPU), also called a central processormain 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:

  1. Is the CPU suitable for a 64-bit operating system
  2. Number of cores in the processor
  • Find CPU information in Linux using lscpu command, just run:
lscpu
  • You can filter your previous results using grep command with a specific detail such as:
lscpu | grep -i 'Model'
  • To find the number of CPU cores, run:
lscpu | grep -i "CPU(s)"

Using /proc/cpuinfo file

  • You can find the CPU info by displaying the contents of /proc/cpuinfo file as follows:
cat /proc/cpuinfo

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

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
  • Use -short option to display only the processor model as shown below
sudo lshw -short -class processor

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

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

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
  • To summarize the latest output for hwinfo, use the –short flag as shown below
sudo hwinfo --short --cpu

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
  • 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 

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook

x