How to Monitor CPU Usage in Linux
Introduction
High CPU usage can slow down your Linux system or indicate a misbehaving process. Monitoring CPU helps you detect and troubleshoot performance issues quickly.
Step 1: Use the top Command
top
➡️ Displays running processes, CPU usage, and memory in real time.
Step 2: Use the htop Command
sudo apt install htop # Debian/Ubuntu
sudo yum install htop # CentOS/RHEL
Run it with:
htop
➡️ Provides a colorful, interactive view of CPU usage with options to kill processes.
Step 3: Check CPU Load with uptime
uptime
➡️ Shows how long the system has been running and the average CPU load.
Step 4: Check Process-Specific Usage
ps -eo pid,ppid,cmd,%cpu,%mem --sort=-%cpu | head
➡️ Lists the top CPU-consuming processes.
Conclusion
By combining top, htop, uptime, and ps, you can effectively monitor CPU usage, spot heavy processes, and keep your system stable.

Comments
Post a Comment