How to Get CPU Info in Linux
Fortunately, Linux offers numerous methods to accomplish any given task, which provides users with a great deal of flexibility. Similarly, if we want to fetch CPU details, multiple command-line tools are available for this purpose.
Let’s go through the various methods to display CPU information on a Linux system.
- lscpu Command
- /proc/cpuinfo File
- cpuid Command
- nrpoc Command
- top or htop Command
- hwinfo Command
- dmidecode Command
- inxi Command
- lshw Command
- hardinfo Tool
(I am going to perform this tutorial on the Ubuntu 22.04 machine).
1. Get CPU Info Using lscpu Command
The lscpu command is a utility that retrieves CPU details from sysfs and /proc/cpuinfo files, displaying the results on the Linux terminal.
Just type the lscpu on the terminal and get the CPU details:
By using the lscpu command tool, you would get the complete picture of CPU data. However, reading these details can be complex. To get a specific or required amount of details like processor, threads, model, or number of cores, the grep command is the best choice.
The Linux grep command tool allows users to find and print specified strings on the Linux terminal. To get detailed information about particular queries, use the combination of the grep and lscpu commands. Make sure to provide the exact name of the queries you need details for.
Let’s suppose I need to find details of my processor model name, cores, threads, CPU family, and NUMA, the command would be:
2. Get CPU Info Using /proc/cpuinfo File
All Linux distributions come with a file called /proc/cpuinfo, which contains detailed information about the CPU architecture in use. To view this information, we can utilize the cat or less command to print the contents of the /proc/cpuinfo file in the terminal.
Run the given command with the /proc/cpuinfo file to get the desired results:
3. Get CPU Info Using cpuid Command
If you’re working in an x86 CPU processor, the Linux cpuid command-line utility is the best choice to find the detailed CPU(s) queries that aren’t available in the lshw or /proc/cpuinfo.
The cpuid command tool is not pre-installed in Linux systems; however, you can get it by installing through the package manager.
Execute the mentioned command in the terminal to start installing cpuid command tool:
Now, simply type the cpuid without passing any argument, and it will display the complete details of the x86 CPU:
4. Get the CPU Info Using nrpoc Command Tool
To find out only the quantity of cores processors present in a Linux system, just type the nproc command in the terminal and you will find the number of cores in the output:
5. Get the CPU Info Using top & htop Command
The top and htop commands are useful for monitoring system performance, including the processor. The htop is the newer version of the top command, offering an interesting and interactive interface for a better understanding of users.
Let’s run both of the commands i-e., top, and htop individually to see the difference:
The htop command tool is not preinstalled in some of the Linux tools, however, you can get it using the apt or snap package manager:
Run the given command in the terminal to install the htop tool on a Linux machine:
Now, type the htop in the terminal to see the results:
6. Get CPU Info Using hwinfo Command
As the name describes, the hwinfo command tool is used to display hardware-related details on the terminal. To install the hwinfo utility on the terminal, run the given apt command:
Now, type the hwinfo to display hardware details on the terminal:
7. Get CPU Info Using dmidecode Command
The dmidecode command in Linux is used to retrieve system hardware data like processor, BIOS, RAM, serial number, and displays it in a human-readable format.
Run the mentioned command to see how the dmidecode command works in a Linux terminal:
8. Get CPU Info Using inxi Command
The inxi command-line utility is another way to print necessary details about the CPU on the screen. To use this tool, first, we need to install it using the apt package manager as mentioned below:
Now, run the inxi command with the -C parameter to show the CPU details:
9. Get the CPU Info Using lshw Command
The lshw is the light-weighted command-line utility used to extract hardware configuration details and generate brief reports on it. Run the lshw command tool with the -C argument to fetch CPU processing details:
10. Get CPU Info Using hardinfo Tool
The hardinfo tool is a popular diagnostic tool for hardware components. This user-friendly tool presents a graphical display that helps to find system hardware details.
To see how hardinfo tool works, we need to install it:
Once you completed the successful installation of hardinfo graphical tool on a Linux machine, type hardinfo in the terminal to display its screen:
Conclusion
As we all know the importance of CPU because the whole system depends on it and it is responsible for the overall performance as well. To keep the system compatible and reliable, it is now necessary to monitor the load and processing details regularly to troubleshoot issues that may arise. This guide has mentioned the multiple command-line tools to display the CPU information on a Linux screen. Some of these tools are pre-installed while some can be installed using our given commands.