How to Find CPU Information in Linux Using Command Line?

The CPU (Central Processing Unit) is the main processing part of the system that performs the data processing operations and also called the brain of the system. The CPU information allows us to manage the running processes in the system and provides information about the type & speed of the CPU.

For debugging hardware-related issues, the CPU information helps to understand these problems from the Command Line utility. The CPU processor plays a vital role in measuring the overall system’s performance.

This article will discuss several methods to find the CPU information using the Command Line. The following methods are enlightened in this post:

Let’s start with the “lscpu” command.

Method 1: Using lscpu Command

The “lscpu” (list CPU) command utility is used to obtain details about the CPU architecture. To get all the CPU information of the system, run the below command:

$ lscpu

The output shows the system CPU features:

Architecture: X86_64, which shows the CPU is “64bit” x86 type.

CPU op-mode(s): 32-bit, 64-bit that shows CPU can work on 32-bit and 64-bit.

CPU(s): 2

Model Name: Intel (R) Core(M) i3-40300 CPU @ 1.90 GHz.

CPU Family: 6

Thread(s) per core: 1

Socket(s): 1, which shows 1 physical CPU is connected to the system.

Method 2: Using /proc/cpuinfo File

The “/proc/cpuinfo” file in the root directory contains the CPU information. To get CPU info, use this command:

$ cat /proc/cpuinfo

The output shows all the details about the CPU that, includes the Number of Processors, CPU family, Model, Model Name, and other required information.

To check the details of the number of cores in Linux only using the /proc/cpuinfo file, use this command:

$ grep -c 'cpu cores' /proc/cpuinfo

The command shows two CPU cores are present in the system.

Method 3: Using cpuid Command

The cpuid utility shows detailed information about the CPU, including the model of the processor in the system. In some linux-distributions cpuid is not installed. To install cpuid, the commands are provided below: 

$ sudo apt install cpuid                       #For Ubuntu.
$ sudo dnf install cpuid                       #For Fedora.
$ sudo yum install cpuid                       #For CentOS/RHEL.

After the installation, run the “cpuid” command to fetch all the information about the CPU as sown below:

$ cpuid

The output shows the architecture details about the CPU.

Method 4: Using dmidecode Command

The “dmidecode” command helps show the system information. To check the processor details (CPU), utilize the command:

$ sudo dmidecode --type processor

The output shows Processor details, including the type of processor, version/model name, and other details about the CPU.

Method 5: Using inxi tool

The inxi tool displays information about the Linux systems; we can utilize inxi to fetch information about the CPU. Before that, you need to install “inxi” by executing one of the following commands:

$ sudo apt install inxi                     #For Ubuntu/Debian.
$ sudo dnf install inxi                     #For Fedora
$ sudo yum install inxi                     #For CentOS/RHEL

The inxi tool “–cpu” or “-C” options are used to display the information about the CPU. Run any of the following commands:

$ inxi -C

The CPU information in a compact way is displayed in the output.

Method 6: Using lshw Command

The lshw (list hardware) shows the details about the hardware of the system. To get CPU details of the system, execute the following command:

$ sudo lshw -C CPU

Method 7: Using top Command

The top command helps to find the overall CPU usage for the running process and CPU consumed by each of the running processes:

$ top

This command is utilized to find CPU consumption and memory as highlighted in the above image.

Method 8: Using hardinfo Command

The hardinfo (hardware info) is utilized to fetch the information of the present hardware. Before using, install the hwifo package and use the below-mentioned command to install hardinfo:

$ sudo apt install hardinfo -y                 #For Debian/Ubuntu-based 
$ sudo pacman -S hardinfo                      # For Arch/Manjaro-based

Now, run the “hardinfo” command in the terminal. It will navigate to the below GUI with the hardware and CPU processor information.

Note: Choose the “Processor” tab to check the information about the CPU.

Method 9: Using hwinfo Command

The “hwinfo” is another command utility to fetch the system hardware information. This package is not installed in some linux-distribution. To install the “hwinfo”, utilize one of the following command:

$ sudo apt install hwinfo                     #For Debian/Ubuntu-based.
$ sudo dnf install hwinfo                     #For Fedora.
$ sudo yum install hwinfo                     #For CentOS/RHEL.

In our case, we installed it on Ubuntu.

For finding the CPU information using the hwinfo command, run the following command:

$ hwinfo --cpu

To get the CPU model name utilizing the hwinfo command, use the below syntax:

$ hwinfo --cpu --short

Method 10: Using nproc Command

If you want to check the processing units in the system with a single command, utilize the below command:

$ nproc

The output shows two (2) processing units CPUs are in the system.

Additional Method: GNOME System Monitor

The GNOME system monitor displays information for real-time Processes, Resources (including CPU consumption), and File Systems. For getting the current CPU usage on the machine/system, navigate to the “Resources” tab. The percentage CPU consumption will be displayed in real-time that is changing according to time per minute.

The below figure shows there are two CPUs in the system, the first is 7.0% used, and the second is 6.1% consumed:

That’s the end of this guide.

Conclusion

To find the CPU information in Linux, lscpu, /proc/cpu, dmidecode, inxi tool, lshw, top, hardinfo, and nproc commands are utilized. We can get these features of CPU architecture, CPU op-mode, Number of CPUs, Model Name, Thread per Core, Sockets, and other information using the commands mentioned in this guide. Several methods are performed to find the CPU information in Linux throughout this article.