How to cpu usage in linux
Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.
Last updated: April 4, 2026
Key Facts
- The `top` command provides a dynamic, real-time view of running processes, sorted by CPU usage by default.
- `htop` is an enhanced, interactive version of `top` with colorized output and easier navigation.
- The `nmon` utility offers a comprehensive system performance overview, including CPU, memory, network, and disk I/O.
- Graphical tools like GNOME System Monitor offer an intuitive, point-and-click interface for monitoring CPU.
- Understanding high CPU usage can help diagnose performance issues and identify resource-hungry applications.
Overview
Understanding and monitoring CPU usage is a fundamental aspect of managing any Linux system, whether it's a personal desktop or a powerful server. The Central Processing Unit (CPU) is the brain of your computer, executing all the instructions that make your software run. When the CPU is constantly working at its maximum capacity, it can lead to slow performance, unresponsiveness, and even system instability. Knowing how to check and interpret CPU usage allows you to identify bottlenecks, troubleshoot problems, and optimize your system's performance.
Why Monitor CPU Usage?
Several reasons necessitate monitoring CPU usage:
- Performance Troubleshooting: High CPU usage by a specific process or the system as a whole is often the primary indicator of performance issues. Identifying the culprit allows you to address the root cause, whether it's a misbehaving application, an inefficient script, or an unexpected system load.
- Resource Management: On servers, especially those hosting multiple applications or services, understanding CPU utilization is crucial for effective resource allocation. It helps in determining if the current hardware is sufficient or if upgrades are needed.
- Security: Sudden spikes in CPU usage, especially if unexplained, can sometimes be a sign of malicious activity, such as cryptojacking malware or denial-of-service attacks.
- Optimization: By observing CPU patterns over time, you can identify opportunities to optimize applications or system configurations for better efficiency.
Command-Line Tools for CPU Monitoring
Linux offers a rich set of command-line utilities for monitoring system resources, including CPU usage. These tools are powerful, versatile, and often preferred by system administrators for their efficiency and scripting capabilities.
1. `top`
The `top` command is a classic and widely available utility that provides a dynamic, real-time view of the processes running on your system. It displays a sorted list of processes, with the highest CPU consumers at the top by default.
How to use `top`:
- Open your terminal.
- Type
topand press Enter.
Key information in `top` output:
- %CPU: The percentage of CPU time the process is currently using.
- %MEM: The percentage of physical memory the process is using.
- PID: The Process ID.
- USER: The user who owns the process.
- COMMAND: The name of the command or program.
Common `top` commands:
- Press
kto kill a process (you'll be prompted for the PID). - Press
Mto sort by memory usage. - Press
Pto sort by CPU usage (default). - Press
qto quit.
2. `htop`
htop is an interactive and user-friendly enhancement to `top`. It offers colorized output, easier navigation, mouse support (in some terminals), and more intuitive ways to manage processes.
Installation (if not already installed):
- Debian/Ubuntu:
sudo apt update && sudo apt install htop - Fedora/CentOS/RHEL:
sudo dnf install htoporsudo yum install htop
How to use `htop`:
- Open your terminal.
- Type
htopand press Enter.
Key features of `htop`:
- Visual Meters: Displays CPU, memory, and swap usage as colorful bars.
- Process Tree: Allows you to view processes in a tree structure, showing parent-child relationships.
- Function Keys: Uses function keys (F1-F10) for common actions like searching, filtering, killing, and sorting.
- Mouse Support: Click on processes to select them and use mouse wheel to scroll.
3. `nmon`
nmon (Nigel's Monitor) is a powerful system administration, monitoring, and benchmarking tool. It provides a comprehensive overview of system performance, including CPU, memory, network, disk I/O, and more, all in a single interface.
Installation (if not already installed):
- Debian/Ubuntu:
sudo apt update && sudo apt install nmon - Fedora/CentOS/RHEL:
sudo dnf install nmonorsudo yum install nmon
How to use `nmon`
- Open your terminal.
- Type
nmonand press Enter.
Key features of `nmon`
- Multiple Metrics: Shows CPU utilization per core, memory usage, network statistics, disk I/O, NFS, and more.
- Interactive Mode: Press keys like 'c' for CPU, 'm' for memory, 'n' for network, 'd' for disk to toggle sections.
- Recording Mode: Can record system statistics to a file for later analysis.
4. `mpstat`
The `mpstat` command (part of the `sysstat` package) is useful for reporting processor-related statistics. It can report global statistics or per-processor statistics.
Installation (if not already installed):
- Debian/Ubuntu:
sudo apt update && sudo apt install sysstat - Fedora/CentOS/RHEL:
sudo dnf install sysstatorsudo yum install sysstat
How to use `mpstat`
- To show CPU utilization for all processors:
mpstat -P ALL - To show CPU utilization every 2 seconds:
mpstat 2
5. `vmstat`
The `vmstat` command reports virtual memory statistics. While its primary focus is memory, it also provides CPU usage information.
How to use `vmstat`
- To show statistics every 2 seconds:
vmstat 2
Key CPU metrics in `vmstat`
- us: user time
- sy: system time
- id: idle time
- wa: wait time (I/O wait)
Graphical Tools for CPU Monitoring
For users who prefer a visual interface, Linux desktop environments offer built-in graphical system monitors.
1. GNOME System Monitor
If you're using the GNOME desktop environment (common in Ubuntu, Fedora), the System Monitor is a user-friendly application.
How to access:
- Search for "System Monitor" in your application menu.
- Alternatively, press
Ctrl+Alt+Deland select "System Monitor" (this shortcut might vary).
Features:
- Tabs for Processes, Resources, and File Systems.
- The "Resources" tab provides real-time graphs for CPU usage, memory usage, and network activity.
- You can sort processes by CPU or memory usage and kill processes directly from the application.
2. KDE System Guard
For users of the KDE Plasma desktop environment (common in Kubuntu, openSUSE), KDE System Guard offers similar functionality.
How to access:
- Search for "System Guard" in your application menu.
Features:
- Provides detailed information on running processes and system resources.
- Offers graphs for CPU, memory, network, and disk usage.
- Allows users to manage processes and monitor system health.
Interpreting CPU Usage
A CPU usage of 100% generally indicates that the processor is fully utilized and cannot keep up with the demands placed upon it. However, brief spikes to 100% are normal during intensive tasks like compiling software, rendering video, or running complex simulations. Persistent high CPU usage (e.g., above 80-90% for extended periods) without a clear reason is usually a cause for concern and warrants investigation.
Look for specific processes consuming a large portion of the CPU. If a familiar application is responsible, consider closing it or restarting it. If an unknown process is consuming significant resources, research its name to understand its purpose and whether it's legitimate.
Conclusion
Regularly monitoring your Linux system's CPU usage is an essential practice for maintaining optimal performance and identifying potential issues early on. Whether you prefer the efficiency of the command line with tools like `top` and `htop`, or the visual clarity of graphical applications like GNOME System Monitor, Linux provides robust options to keep your system running smoothly.
More How To in Daily Life
Also in Daily Life
More "How To" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- Top (command) - WikipediaCC-BY-SA-4.0
- htop(1) - Linux man pagefair-use
- nmon(1) - Linux man pagefair-use
Missing an answer?
Suggest a question and we'll generate an answer for it.