Getty Images/iStockphoto


How to check your CPU in a Linux system

You can issue commands through your Linux CLI to gather CPU information, including detailed information on cores, class, virtualization support, architecture and usage.

To troubleshoot or build a software stack, you must not only know what type of architecture you work with, but also the details about your hardware and its performance. When it comes to Linux, you can gather that information via the command-line interface. The Linux CLI can provide you with detailed CPU information, such as the number of CPU cores, CPU architecture and CPU usage.

You can use several specific commands to pull CPU information from your hardware, regardless of whether you use bare metal or virtualized hardware. These commands should work on any Linux distribution and should come preinstalled on your systems.

Checking your CPU in Linux

You can use a single command to gather general information about your CPU. This basic command displays a considerable amount of CPU information. That command is:


When you run that command without any arguments, it returns a large amount of information -- more information than you probably normally need.

Fortunately, you can weed out some of that information by implementing additional arguments. For example, if you only want information about the CPU make and model, number of sockets, number of CPU cores, thread per core and total threads, you can pipe the lscpu command to grep:

lscpu command in Linux CLI
The lscpu command returns more information than you usually require.

lscpu | egrep 'Model name|Socket|Thread|NUMA|CPU/(s/)'

The output then becomes easier to read and use.

lscpu output piped through grep
The output of lscpu piped through grep is much more succinct.

With this information, you can discern what types of applications and services you can run on a machine.

How to find out if your CPU supports virtualization

If you intend to use a system for virtualization, you must first know whether the CPU can support virtualization technology. You can use the same lscpu command to find this. Once again, you pipe it through grep, but this time, have it check for the Virtualization flag:

lscpu | grep 'Virtualization'

If the output lists VT-x, then that CPU is enabled for virtualization. If you don't see VT-x listed, you must use a different machine.

How to check your CPU hardware class information

To get detailed, in-depth information on the CPU class, use sudo privileges with the lshw command:

sudo lshw -C CPU

The output of the above command should give you more in-depth detail about your CPU, including the slot type, size, capacity, width, clock speed, vendor and ID.

lscpu output piped through grep
The output of lscpu piped through grep is much more succinct.

How to get even more detailed information

If you want to gather as much detailed information about the CPU as possible, you can read out the contents of the cpuinfo file with the following command:

cat /proc/cpuinfo

You'll find a significant amount of information here, which requires you to page through. If the terminal you're working in doesn't scroll, pipe the command through less:

cat /proc/cpuinfo | less

cat /proc/cpuinfo command output
Similar to lscpu, the output of cat /proc/cpuinfo can be overwhelming without any arguments.

The output from cpuinfo includes sections for every CPU in your system. For example, a system with 16 CPUs lists information for CPUs 0-15.

How to check CPU usage

You can check how your CPU is being used with the htop command. This prints out real-time information that includes tasks, threads, load average uptime and usage for each CPU.

To run this tool, issue the command:


You should see a real-time display with information on how your CPU is being put to use.

htop command output
Using htop to view real-time statistics for system CPUs.

If you need to learn more about a specific command, you can read the man page -- such as man htop or man lscpu -- for that command.

Dig Deeper on Linux servers