How To Check Cpu Utilization In Linux Command

6 min read

How to Check CPU Utilization in Linux Command

Checking CPU utilization in Linux is a fundamental skill for system administrators, developers, and power users who need to diagnose performance issues, optimize workloads, and check that resources are allocated efficiently. Think about it: understanding how to read the output of various Linux utilities not only helps you identify bottlenecks but also deepens your knowledge of how the operating system manages processes and schedules tasks. In this guide, we’ll walk through the most common and reliable commands for monitoring CPU usage, explain the underlying concepts, and provide practical tips for interpreting the data But it adds up..

Introduction

When you open a terminal and type a command to check cpu utilization in linux command, you gain instant insight into how your system’s processor is being used. Whether you’re troubleshooting a sluggish server, tuning a containerized application, or simply curious about resource consumption, the right tools make the difference between guesswork and data‑driven decisions. This article covers the essential commands—top, htop, ps, iostat, mpstat, and glances—along with their options, how to install missing utilities, and what the numbers actually mean. By the end, you’ll be comfortable running these commands and interpreting their output to keep your Linux machines running smoothly Small thing, real impact..

Understanding CPU Utilization Metrics

Before diving into the commands, it’s helpful to know what “CPU utilization” really means. In Linux, CPU utilization is expressed as a percentage that reflects the amount of time the processor spends executing tasks versus being idle. The kernel tracks this at two levels:

Quick note before moving on It's one of those things that adds up. No workaround needed..

  • Per‑process – how much CPU time a specific program consumes.
  • Overall system – the aggregate usage across all cores and threads.

Most utilities display data in one of two formats:

  1. Percentage of total CPU time – e.g., 45 % means the CPU is busy for 45 % of the observed interval.
  2. Load average – a dimensionless number representing the number of processes waiting for CPU time.

When you check cpu utilization in linux command, you’ll often see both types of metrics side by side, which helps you gauge whether high load is due to many processes or a few CPU‑intensive ones.

Step‑by‑Step Commands to Monitor CPU Usage

Below are the most widely used commands, presented in order of simplicity and frequency of use.

1. Using top

top is a classic, built‑in utility that provides a dynamic, scrollable view of running processes and system statistics. It’s ideal for quick checks and for watching real‑time changes Most people skip this — try not to..

Basic usage

top

top displays a summary at the top of the screen that includes:

  • CPU usage – a percentage for each CPU core and an overall “%Cpu(s)” line.
  • Memory usage – total, used, and free RAM.
  • Load averages – 1, 5, and 15‑minute averages.

To make the output easier to read, press H to hide the header, q to quit, and k to kill a process. You can also press P to sort processes by CPU usage That's the part that actually makes a difference..

Key options

  • -b – batch mode (non‑interactive, useful for scripting).
  • -n 3 – run for 3 iterations and exit.
  • -d 2 – delay between updates (in seconds).

Example batch output

top -b -n 3 -d 2

This command runs top three times, waiting two seconds between each refresh, and prints the results to standard output Worth keeping that in mind. And it works..

2. Using htop (if installed)

htop is a more user‑friendly alternative to top. It offers a colored, interactive tree view of processes and includes per‑core CPU meters at the bottom of the screen. Many modern distributions ship htop as part of the “htop” package Simple, but easy to overlook..

Installation (Debian/Ubuntu)

sudo apt-get install htop

Installation (RHEL/CentOS/Fedora)

sudo yum install htop   # or sudo dnf install htop

Basic usage

htop

Press F6 to sort by CPU usage, F4 to filter processes, and F9 to nice/kill a process. htop also shows a graphical CPU usage bar for each core, making it easier to spot spikes.

Batch mode

htop -b -n 5

The -b flag enables batch mode, while -n specifies the number of iterations That's the whole idea..

3. Using ps

The ps command provides a snapshot of running processes and can be used to extract CPU usage statistics without launching an interactive viewer And that's really what it comes down to..

Basic usage

ps aux --sort=-%cpu | head -n 10

Explanation:

  • aux – shows all processes for all users, with full command lines.
  • --sort=-%cpu – sorts by CPU usage descending.
  • head -n 10 – limits output to the top ten CPU‑hungry processes.

Common options

  • -o %cpu,pid,cmd – custom columns (CPU %, PID, command).
  • -e – select all processes.
  • -f – full format.

4. Using iostat

iostat (part of the sysstat package) reports average CPU and I/O statistics for disks and partitions. It’s especially useful for correlating CPU load with disk activity Turns out it matters..

Installation

sudo apt-get install sysstat   # Debian/Ubuntu
# or
sudo yum install sysstat       # RHEL/CentOS

Basic usage

iostat -xk 1 5
  • -x – display extended statistics (including %util).
  • -k – show statistics in kilobytes.
  • 1 – interval between reports (seconds).
  • 5 – number of reports.

The output includes columns like %usr, %sys, %iowait, %idle, and %util. The %util column shows the utilization of the device (0‑100 %). For overall CPU, focus on %usr, %sys, and %iowait.

5. Using mpstat

mpstat (also from sysstat) provides detailed CPU statistics per processor, which is invaluable when you have multi‑core or multi‑threaded systems.

Installation – same as iostat.

Basic usage

mpstat 2 3
  • First 2 – interval between reports (

seconds. Second 3 – number of reports to display.

The output breaks down CPU activity per processor, showing columns such as %usr (user time), %sys (system/kernel time), %iowait (time spent waiting for I/O), %irq and %soft (hardware and software interrupt handling), %steal (time stolen by a hypervisor in virtualized environments), and %idle. Elevated %iowait usually signals a disk or storage bottleneck rather than a CPU shortage, while consistently high %sys can indicate excessive kernel activity or driver issues.

To view statistics for every processor individually:

mpstat -P ALL 1

The -P ALL flag reports each core separately, which is useful for detecting imbalanced workloads where a single core is saturated while others remain idle.


Conclusion

Linux offers several complementary tools for monitoring CPU usage, and the right choice depends on whether you need real-time interaction, a quick snapshot, or detailed historical analysis Surprisingly effective..

  • top is the universal, always-available option for live process monitoring.
  • htop improves on that experience with color, intuitive navigation, and per-core visualization, making it ideal for day-to-day troubleshooting.
  • ps delivers a lightweight, scriptable snapshot of the most CPU-intensive processes without launching an interactive interface.
  • iostat helps correlate CPU load with disk activity, highlighting whether %iowait is dragging down performance.
  • mpstat provides granular, per-core CPU metrics, essential for multi-core systems and virtualized environments.

For routine checks, start with htop or top. Use ps when you need a fast list of top consumers, and turn to iostat or mpstat when you need to determine whether high CPU figures are caused by computation, kernel overhead, or waiting on I/O. Combining these tools gives you a complete picture of system health and helps pinpoint performance bottlenecks before they affect users.

This is where a lot of people lose the thread.

New Content

Out This Week

Similar Vibes

Before You Go

Thank you for reading about How To Check Cpu Utilization In Linux Command. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home