1. How to Easily Check CPU Usage on Ubuntu
The Importance of Monitoring CPU Usage on Ubuntu
Monitoring CPU usage is crucial for system administrators. If resources become insufficient, system performance can degrade. Regularly checking usage is recommended. This article provides a detailed guide on commands to check CPU usage in an Ubuntu environment.
2. Basic Methods to Check CPU Usage on Ubuntu
How to Use the top Command
The top
command is a fundamental tool for checking CPU usage. It displays real-time CPU usage per process, memory usage, and overall system status. When you run top
, you will see a screen like the one below.
top

Pressing the 1
key allows you to view the usage of each CPU core. Additionally, pressing Shift + M
sorts the processes by memory usage.
Customizing the top Command
The top
command allows you to customize columns to display only the necessary information. By pressing the f
key, you can select or hide specific columns, making it easier to organize CPU and memory usage details efficiently.
3. Advanced Monitoring Tools
Using the htop Command
The htop
command provides a more visually intuitive interface compared to top
, with color-coded resource usage per process. You can install htop
using the following command:
sudo apt-get install htop
When executed, it displays a screen like the one below.
htop

htop
allows mouse interaction, and you can use function keys (F keys) to filter and sort data. Additionally, pressing F3 enables searching for specific processes quickly.
Monitoring System Performance with the vmstat Command
The vmstat
command provides an overview of system performance, including memory, CPU, and I/O operations. The following command displays CPU usage and memory status every second:
vmstat 1
This command shows average resource usage since the last system reboot. If you need to monitor resource usage regularly, you can output the data to a file for analysis.

4. Case-Based CPU Usage Monitoring
Long-Term Resource Monitoring
When the system experiences high load for extended periods, using vmstat
to log CPU and memory usage is recommended. The following command records CPU usage every second:
vmstat 1 > cpu_usage.log
This helps identify patterns of resource spikes at specific times.
Checking for Sudden Spikes in Load
Using top
or htop
, you can monitor sudden load spikes in real-time and take immediate action. This allows you to quickly identify processes causing issues.
5. Summary and Best Practices
Regular resource monitoring is essential to ensure system stability. Tools like top
and htop
allow for real-time CPU usage monitoring, making it easy to track system performance. Additionally, using tools like vmstat
and dstat
can help collect detailed data and analyze long-term resource usage trends.