8 Best commands to check the information about the CPU

 Introduction

Knowledge of your CPUinformation is important when you are trying to debug a performance-related issue, when you are upgrading your hardware, or when you are just trying to understand how your Linux-based system works. Linux has several built-in tools that enable you to obtain information about CPU architecture, usage statistics, and temperature values among others.

In the previous guide we have talked about how to monitor systems with the aid of top and htop, and this guide refer to the most useful commands to get the information about the CPU in Linux.

Before checking the system info, OS understanding is the essential. Start with our guide What is Linux? An Introduction to Linux and Its Popular Distributions.

1. lscpu - Quick Summary of the CPU Architecture

One of the most convenient tool to check CPU information is the lscpu. It gets information for /proc/cpuinfo and sysfs, then prints it in a clean and the readable format.

#lscpu

 lscpu command output is showing the CPU architecture and the processor details in the Linux terminal

What You Can Learn

  • CPU Architecture and op-mode
  • Address size
  • Vendor ID
  • Model name
  • CPU family and sockets
  • Number of cores and threads
  • Virtualization Features, etc.

One can get a quick summary of the CPU information without having to read the configuration files with lscpu.


Many info commands of the system run from the terminal. Learn essential commands in 10 Linux Basic Commands Every Beginner Should Know.

2. cat /proc/cpuinfo – Per Core Detail

The information provided by the /proc/cpuinfo is the raw CPU information that is obtained directly from the kernel. Unlike lscpu, this file displays per core information and is useful for the advanced analysis.


#cat /proc/cpuinfo                                                           Linux cat /proc/cpuinfo command output is showing the CPU model, cores, threads and the processor information


What You Can Learn

  • Vendor_id and CPU family
  • Model and model name
  • Stepping
  • CPU MHz
  • Cache size
  • Core id and CPU cores, etc.
The /proc/cpuinfo is the easiest way to determine the exactly what set of instructions your CPU supports.

3. top and htop – Real Time Usage of the CPU Monitoring

a) top
top is by default installed on every Linux system and helps to monitor real-time CPU usage.

#top
 Linux top command output is showing the real-time system monitoring with CPU, memory and the running processes

b) htop
Htop is a user friendly alternative with color coded graphs but you need to install it before using it.
To install the htop command is

#sudo apt install htop
#htop
Linux htop command interface is showing the CPU cores usage, memory consumption and the active processes

What You Can Learn

4. mpstat – CPU Usage for All Cores
Mpstat is part of the sysstat package and is commonly used for the performance monitoring.

#mpstat
 mpstat command output is showing the per CPU usage statistics and the processor performance in the Linux terminal

mpstat command output is showing the per CPU usage statistics and the processor performance in the Linux terminal

What You Can Learn

  • CPU usage per core
  • Idle time
  • iowait
  • Soft IRQs
  • User/system time distribution

5. nproc – Number of Processing Units
At times you wish to know the number of CPU cores that your system is capable of utilizing. It shows the number of available processing units of CPU (cores/threads). Mostly, developers used it to set the optimal compile time for parallel jobs.

#nproc
The nproc command output is showing the number of available CPU cores in the Linux terminal

6. dmidecode – CPU Hardware Specification
Dmidecode is the extremely helpful in case you need to know the CPU information at the BIOS/hardware level.

#sudo dmidecode –t processorsudo dmidecode -t processor command output  is showing the detailed CPU hardware information in the Linux terminal

What You Can Learn

  • CPU socket type
  • Maximum supported speed
  • Current speed
  • Manufacturer
  • Version and status
  • Voltage information
This is helpful when checking the hardware compatibility before upgrading the components.

7. Sensors – Measures the CPU Temperature
If you want to monitor the thermal conditions, lm-sensors can detect the available sensors.

Install lm-sensors

#sudo apt install lm-sensors

#sudo sensors-detect

Then run the command

#sensors

What You Can Learn
  • CPU temperature
  • Voltage readings
  • Fan speeds 
For troubleshooting and rectifying the overheating issue, monitoring of CPU temperature is important.

System info commands are useful for the troubleshooting security issues. Secure your servers by reading How to Secure SSH Access on Linux.

8. inxi – Comprehensive CPU Summary
Inix provides a clean and detailed summary CPU and system information.

Install inxi

#sudo apt install inxiLinux inxi command output is showing the CPU, memory, kernel version and the system hardware details

Now run the inxi command

#inxi -C
Linux inxi command output is showing the CPU, memory, kernel version and the system hardware details

What You Can Learn

  • Model name
  • Cores count
  • Speed
  • CPU min/max frequencies
It is a great tool to create system reports. Linux offers a variety of built-in and optional tools to help admins to gather the detailed CPU information. In case you want a fast overview on what is going on in real-time, hardware status or temperature data, then the commands in this guide will be useful.

Most Recommended Commands

  •  lscpu – Best quick overview
  • /proc/cpuinfo – Raw detail data
  •  htop – Real-time monitoring
  •  mpstat – Per-core usage stats
  •  sensors – Temperature monitoring

That’s all for now. Regularly use these tools to keep the track of your system's performance, troubleshoot issues and gain a better understanding of your system. Keep on going to the seeklinux to updated information and the tutorials. Feel free to send us your comments and feedback.

Post a Comment