9 Useful Commands to Get CPU Information on Linux

Published on December 18, 2023

Getting information about your CPU is handy at times. Maybe you want to know how many processors you have, or maybe you recently accessed a new machine and want to check its CPU information to understand how best to utilize it. Whatever the reason, you should know which commands you should use to get CPU information on Linux. Reading this post introduces you to 9 useful commands to get CPU information on Linux.

How to Get CPU Information on Linux Using Commands

Linux gives you supremacy by providing the command line to execute commands to achieve any task, including getting CPU information. Below are 9 useful commands you should know for checking the CPU information on your Linux machine. Note that the functionality of the commands will differ. Thus, you will notice that some commands give more information than others. Nonetheless, let’s check them out.

1) /proc/cpuinfo

CPU-related information is stored in the /proc/cpuinfo location on your Linux. Therefore, reading this file using a command like cat or less will display all the CPU details

Copy

You will get all the CPU information in the file, as in the image below.

This display makes it easy to go through and find any detail you want to check regarding the CPU.

Suppose you are only interested in getting a specific detail. You can add the grep command to filter the output. For instance, to only get the ‘model name’ from the CPU details, run your command as shown below.

Copy

2) lscpu

A command like lscpu will fetch the CPU information from files such as /proc/cpuinfo and display them on the terminal. However, it doesn’t give details information like we got earlier. Besides, it uses different locations to get and display the CPU information.

Run the command with no option; you will get CPU information such as vendor and architecture.

Copy

3) dmidecode

Although the dmidecode command is mainly used for getting hardware information, adding the –type processor option will filter the CPU details from the computer’s DMI details.

Run the command as follows.

Copy

Notice how, under DMI type 4, we get the processor information displayed in a human-readable format. That’s how you use this command to retrieve CPU information.

4) hardinfo

With the hardinfo command, you will get a GUI that allows you to generate a report showing details about your hardware components. From this report, you will get the CPU information for your system.

The hardinfo command-line utility doesn’t come pre-installed. Run the install command below.

Copy

Once it installs, run the command below to bring up the interface.

Copy

Under the CPU section, you will get all the CPU-related information about your system.

5) nproc

For someone looking only to get the number of processing units available in their system, the nproc command is the ideal choice. When executed, it only shows the number of processing units. However, it may sometimes not give the actual number of cores you have. Despite this, it’s a great tool for quickly getting CPU information.

6) hwinfo

The hwinfo is run when you want to get hardware information about your system. When you add the –cpu option, it will display CPU information.

The utility can be installed using apt, as the command below demonstrates.

Copy

Below is an example of how to run it.

The output shows all the CPU information about your system, and you can check through to find any specific information you wish to retrieve.

7) cpuid

If using AMD or Intel x86 processors, the cpuid retrieves the CPUID information from the system. The command does an excellent job of showing the CPU information, arranging them neatly for you to understand everything quickly.

However, you must first install the cpuid utility with the command below.

Copy

After installing cpuid, run the command without any option, and it will display CPU information from CPUID, as shown in the below image.

All the retrieved CPU information from the CPUID instructions will get dumped on your terminal.

8) inxi

This command runs as a script and utilizes other programs to display a report about the hardware components on your machine.

Start by installing it.

Copy

Running it with no option will give details about key hardware components on the system.

However, adding the -C flag filters the results only to show the CPU-related information. Take a look!

Copy

You now get crucial information about your CPU, such as the model, speed, core, etc.

9) lshw

The lshw will display hardware information, but you can utilize it to get limited CPU information for your system. For this case, we will use the -C option for class and specify CPU as the target class to get its details.

Copy

Although it gives limited information, you can confirm from the below image that all the crucial information about the CPU is successfully retrieved.

Conclusion

The Linux command line is powerful, and when you master it, you can quickly and effortlessly perform numerous tasks. When working with Linux, checking your CPU is handy, and there are numerous commands that you can use. This post has shared 9 useful commands to get CPU information on Linux. Go through the commands and find the most applicable ones for your case.

New to LinuxMeta? Get Started Now! 

Instantly Deploy Linux & Windows KVM VPS at a Cheap Price