Master Linux Process Management and System Monitoring with Top, Htop, and ps
Learn how to diagnose CPU, memory, and I/O bottlenecks on Linux by using Top, Htop, ps, kill, and background‑task commands to pinpoint resource‑hungry processes and resolve performance issues without blind reboots.
1. Command‑line Task Managers: Top and Htop
Running top displays a real‑time list of processes with columns such as PID, USER, %CPU, %MEM, and COMMAND; press q to quit.
Htop offers a more visual, mouse‑friendly interface. Install it with sudo apt install htop and start with htop. Key shortcuts:
F6 – sort by CPU or memory
F9 – kill a selected process
F10 – exit
2. Process Management Commands
ps (Process Status)
View a snapshot of current processes. Examples:
ps aux # show detailed info for all processes
ps aux | grep nginx # find processes related to nginxkill
Terminate processes. Examples:
kill PID # graceful termination (SIGTERM)
kill -9 PID # forceful termination (SIGKILL), use with caution
killall firefox # kill all processes named firefoxTypical workflow: try kill first and wait; if the process remains unresponsive, use kill -9. The -9 flag acts as a “stop‑loss” button but may prevent data from being flushed to disk.
Background Execution
Ctrl+Z – suspend the current foreground job and move it to the background. bg – resume a suspended job in the background. fg – bring a background job back to the foreground. command & – start a command directly in the background (e.g., python server.py &).
3. System Resource Monitoring
System Monitor (GUI)
Ubuntu includes a graphical task manager similar to Windows Task Manager; launch it by searching for “System Monitor” in Activities.
btop
A highly visual CLI monitor that even supports game‑pad input.
sudo snap install btop4. Fault Diagnosis Workflow: Identify the Bottleneck Type
Overall Load
Run uptime to see the load average, which quickly indicates whether the system is constantly queuing tasks.
CPU Busy – Find the Top CPU Consumers
ps -eo pid,comm,%cpu,%mem --sort=-%cpu | headMemory Shortage – Check for Swapping
free -hIf Swap usage continuously rises and the system slows down, the issue is likely memory pressure. Before killing processes, verify whether a memory leak, excessive browser tabs, or an oversized container is the root cause.
I/O Stuck – Low CPU but Slow System
Typical signs are low CPU usage while file opens and application launches are sluggish. First check disk space, then identify processes with heavy I/O using the I/O columns shown in htop.
5. Practical Troubleshooting Scenario
Open a terminal and run htop.
Press F6 and select %CPU to sort processes by CPU usage.
Notice a process named chrome consuming 100% CPU.
Select that process, press F9, choose SIGKILL, and confirm.
The system becomes responsive again.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ubuntu
Focused on Ubuntu/Linux tech sharing, offering the latest news, practical tools, beginner tutorials, and problem solutions. Connecting open-source enthusiasts to build a Linux learning community. Join our QQ group or channel for discussion!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
