How to Check CPU Usage in Linux (Simple Commands for All Distros)

Monitoring CPU usage is one of the most basic yet most important tasks in Linux system administration.
Whether you’re troubleshooting performance issues, checking resource hungry processes, or managing servers, knowing how to check CPU usage helps you keep your system stable and efficient.

Linux gives you several ways to monitor CPU usage both command-line and GUI methods. Let’s go through the best ones.


1. Check CPU Usage Using the top Command

The top command is the simplest and most commonly used tool.

Just open your terminal and type:

top

You’ll see output like this:

top - 11:30:45 up 1 day,  2:11,  1 user,  load average: 0.52, 0.40, 0.36
Tasks: 203 total,   1 running, 202 sleeping,   0 stopped,   0 zombie
%Cpu(s):  8.3 us,  2.1 sy,  0.0 ni, 88.9 id,  0.3 wa,  0.0 hi,  0.3 si,  0.0 st
MiB Mem :   7855.3 total,   1023.4 free,   3467.5 used,   3364.4 buff/cache

Explanation:

  • %Cpu(s) shows the CPU load distribution:
    • us: user space (apps)
    • sy: system (kernel)
    • id: idle
    • wa: waiting for I/O
  • load average: system load in the last 1, 5, and 15 minutes

Press q to quit the top interface.

Why it’s useful:
top gives you a real-time view of CPU usage and lets you spot heavy processes instantly.


2. Use the htop Command (Interactive and Colorful)

htop is like a modern, user-friendly version of top — with colors, graphs, and easy navigation.

To install it:

# On Ubuntu/Debian
sudo apt install htop

# On Fedora/CentOS
sudo dnf install htop

Run it:

htop

You’ll see a beautifully formatted display with:

  • CPU usage bars for each core
  • Memory and swap usage
  • List of processes (sortable by CPU, memory, or user)

You can use arrow keys to navigate, F6 to sort, and F9 to kill a process.

Why it’s great:
It’s easy to read, interactive, and ideal for monitoring multi-core systems in real time.


3. Check CPU Usage with mpstat

If you want detailed CPU usage per core, use the mpstat command (part of the sysstat package).

Install it first:

sudo apt install sysstat

Then run:

mpstat -P ALL

Example output:

Linux 5.15.0-91-generic (ubuntu-pc)  10/04/2025  _x86_64_  (8 CPU)

12:00:01 AM  CPU    %usr   %sys   %idle
12:00:01 AM  all    3.24   1.09   95.67
12:00:01 AM  0      2.03   1.25   96.72
12:00:01 AM  1      3.12   1.02   95.86

Why it’s useful:
It shows how much each CPU core is used — great for performance tuning or checking load balance.


4. Check CPU Usage Using vmstat

vmstat (Virtual Memory Statistics) gives a quick snapshot of CPU, memory, and system performance.

Run:

vmstat 1 5

This runs the command every second for 5 iterations.

Example:

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  0      0 118548  27800 612244    0    0     5     2   31   52  2  1 97  0  0

Focus on:

  • us: user time
  • sy: system time
  • id: idle time

Why it’s useful:
It’s great for scripting and automated performance checks.


5. Check CPU Usage with sar

The sar command (System Activity Reporter) helps you monitor and record CPU usage over time.

Install it (if not already):

sudo apt install sysstat

Check CPU usage for all cores:

sar -u 1 5

This displays CPU stats every 1 second, 5 times.

Example output:

12:01:23 AM  all  3.12  1.08  0.00 95.80
12:01:24 AM  all  4.25  1.19  0.00 94.56

Why it’s great:
Unlike top, sar can log CPU data over time — perfect for analyzing long-running server performance issues.


6. Use ps Command to Check Which Process Uses Most CPU

If you just want to know which process is eating CPU, use:

ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head

Output example:

  PID  PPID CMD                         %MEM %CPU
 2345  1234 /usr/bin/firefox             7.2 35.6
 1346     1 /usr/bin/gnome-shell         4.8 15.3

Why it’s handy:
It shows top CPU-consuming processes in a clean list — great for quick troubleshooting.


7. Check CPU Usage with nmon

If you like visual monitoring tools in the terminal, try nmon.

Install it:

sudo apt install nmon

Run:

nmon

Press:

  • C – show CPU usage
  • M – show memory
  • N – show network stats

Why it’s awesome:
It’s a lightweight performance monitor for everything — CPU, memory, disks, and network.


8. GUI Tools to Check CPU Usage in Linux

If you’re using a Linux desktop environment (like Ubuntu, Fedora, or Mint), you can check CPU usage without using commands.

For Ubuntu (GNOME):

  • Open System Monitor
  • Go to Resources tab
  • You’ll see CPU, memory, and network graphs in real time.

For KDE Plasma:

  • Open KSysGuard (or System Monitor in newer versions)
  • CPU load graphs are displayed under Performance.

Why it’s good:
Ideal for beginners or those who prefer visual tools over terminal commands.


9. Bonus: Real-Time CPU Usage with watch

You can combine watch with other commands to continuously monitor CPU stats.

Example:

watch -n 2 "grep 'cpu ' /proc/stat"

or

watch -n 1 "ps -eo pid,comm,%cpu --sort=-%cpu | head"

Why it’s helpful:
It refreshes the output every few seconds like a mini real-time dashboard.


Quick Comparison Table

CommandDescriptionBest For
topReal-time CPU, memory, and processesGeneral monitoring
htopInteractive, colorful viewEveryday use
mpstatPer-core CPU usagePerformance tuning
vmstatOverall system performanceAutomation scripts
sarHistorical CPU dataLong-term analysis
psTop CPU processesQuick checks
nmonGraphical TUI monitorAdvanced monitoring
GUI ToolsVisual system statsDesktop users

Which Command Should You Use?

Here’s a quick summary depending on your goal:

  • For quick real-time CPU view: top or htop
  • For detailed per-core usage: mpstat
  • For long-term monitoring: sar
  • To find CPU-hogging processes: ps
  • For visual desktop view: System Monitor
  • For scripting: vmstat

If you just want the easiest solution, go with:

htop

It’s visually clear, beginner-friendly, and covers everything you need.


Why Monitoring CPU Usage Matters

Whether you’re managing a Linux server or just using a laptop, monitoring CPU usage helps you:

  • Detect runaway processes consuming resources
  • Diagnose performance bottlenecks
  • Plan upgrades or resource allocation
  • Improve system stability and uptime

In servers, high CPU usage can slow down apps or crash services — so being able to quickly diagnose CPU issues is a key sysadmin skill.


Conclusion

Checking CPU usage in Linux is simple once you know the right commands.
Start with top or htop for a quick overview, and explore tools like mpstat or sar for deeper analysis.

These tools come built-in or are easy to install, making Linux one of the most transparent and powerful systems for resource monitoring.


Discover more from PratsDigital

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *