When a system has limited hardware resources, optimization of resources provides a great help for improving the performance of the system. These resources can be memory, CPU, or storage devices. Ubuntu 22.04 provides many tools to monitor as well as optimize these resources. CPU is the most important component of a system. The overall usage and management of the CPU can improve the performance of the system. 

In this article, we will learn, how you can get to know the overall CPU usage by using different methods.

Get Overall CPU Usage On Ubuntu 22.04.

The performance of the system is directly linked to the CPU of the system. A system can be as fast as its CPU can execute the instructions that are waiting. Most of the time, a processor has a limited speed, but we can improve its performance by optimizing and monitoring its usage across the different processes. 

Let’s start our monitoring process by using different steps:

Step 1: Determining the CPU Load

The number of processes that are using the CPU one core at a specific time or waiting for that core to use it is called CPU Load. CPU Load can be determined by using the following command:

$ uptime

The command gives us the overview of the CPU load at the average of 1-5 and 5, 15-minute intervals:

In my case, 5 minutes interval, has a load of 1.44 for one core, the other core has a load of 0.94 and the third core has a load of 0.43. I have a processor, that has 3 cores running. In your case, it may differ. However, you can check the number of cores by using the following command:

$ cat /proc/cpuinfo |grep core

The command will display the number of cores of your system:

Now we will check the CPU usage. 

Step 2: Determining the CPU Usage

The number of tasks that are executed by the CPU in a percentage of time is called the usage of the CPU. You can use the following command to determine CPU usage:

$ vmstat 3 4

The command will display a 3×4 table of system stats as shown below:

The pointed column of CPU provides the information on processor time spent on different tasks. 

You can also determine the CPU percentage usage by specifying the following command:

$ echo "CPU Usage: " $[100 -(vmstat 1 2|tail -1|awk '{print $15}')]"%"

The command will display the percentage usage of the processor:

In my case, the percentage usage of the processor is 3% only.

Another way of getting the CPU usage stats is by using the /proc/stat file. You can use the following command to determine the CPU usage:

$ cat /proc/stat

The command will display all the stats since boot time:

The command displays the number of processors, boot time, the total number of processes since boot time, processes that are running, and the number of processes that are blocked. 

Another simple, “top” command can also be used to determine the total usage of the CPU:

$ top

The command will display the following result:

The top command displays the details more comprehensively. It displays the number of processors, the usage of each processor, and the load on each processor, along with a detailed table. This table displays the stats of other resources also, like “Memory” usage percentage is also displayed. 

These were some commands that can be used to determine the Load and usage of the CPU in Ubuntu 22.04. But as we are talking about Ubuntu 22.04, the other method of determining the CPU usage can be GUI. Ubuntu 22.04 provides many GUI utilities to monitor the system resources, so now we’ll check the GUI method also.

Determining the Overall CPU Usage using GUI

Ubuntu 22.04 provides a system monitor tool that provides the GUI facilities to monitor the system resources. Follow these steps to determine the Usage of the CPU using the “System Monitor” tool. 

  • Click on the Activities menu button in Ubuntu Desktop:
  • Now navigate to the System Monitor application program, and open the program:
  • The following window will show the details of the running processes:
  • Click on the “Resources” tab from the top bar menu:
  • Now you can see the usage of the CPUs:

This is how you can use the System Monitor program to see the overall usage of the CPU. I hope that this article has comprehensively explained possible ways and it will help you if you follow the given steps.

Conclusion

To get overall CPU usage on Ubuntu 22.04, you can use the terminal by using the different commands that are described in the article and you can also use GUI. In GUI mode you can use the System Monitor program for determining the overall usage of the CPU. In this article, we have learned how we can get information about the usage of the CPU in Ubuntu 22.04.