AI Reading
Quick summary of this article
This chapter explains how to manage processes in WSL Ubuntu, covering essential commands to view, monitor, control, and prioritize running programs for better system performance and troubleshooting.
- Use
ps auxfor a snapshot of all running processes with details like PID, CPU, and memory usage. topshows real-time process activity, whilehtopoffers an interactive, user-friendly interface (install withsudo apt install htop).- Terminate processes with
kill PID(default TERM signal) or force kill withkill -9 PID;pkillandkillallwork by process name. - Adjust process priority using
nice -n 10 command(higher number = lower priority) orrenice -n 5 -p PIDfor running processes. - Key commands for daily use:
ps aux,top/htop,kill, andnice/renice.
Chapter 9: Managing Processes in WSL Ubuntu
Every program or command you run in Linux is a process. Learning how to view, monitor, and control processes is essential for system performance and troubleshooting in WSL Ubuntu.
This chapter will guide you through process management commands, including ps, top, htop, kill, and nice.
📌 Viewing Processes
📌 ps – Snapshot of Running Processes
ps aux
a– All usersu– Display user/ownerx– Include processes without a terminal
Example output shows PID, CPU/memory usage, and command.
📌 top – Real-time Process Monitor
top
Displays dynamic, real-time process information including CPU and memory usage.
q– Quitk– Kill process by PIDh– Help
📌 htop – Enhanced Process Viewer
sudo apt install htop
htop
Provides an interactive interface for monitoring and managing processes. Use arrow keys to navigate, F9 to kill, F6 to sort.
🔪 Terminating Processes
📌 kill – Send Signals to a Process
kill PID
Sends the default TERM signal to terminate a process.
📌 Kill with Specific Signal
kill -9 PID # Force kill
📌 Using pkill or killall
pkill processname
killall processname
⚡ Adjust Process Priority
📌 nice – Start Process with Priority
nice -n 10 command
Higher number → lower priority.
📌 renice – Change Priority of Running Process
sudo renice -n 5 -p PID
🧪 Practice Exercises
# View all running processes
ps aux
# Monitor processes in real-time
top
# Install and use htop
sudo apt install htop
htop
# Kill a process
kill 1234
kill -9 1234
# Start a process with lower priority
nice -n 15 longtask.sh
✅ Summary
ps– Snapshot of processestop– Real-time process monitorhtop– Interactive, user-friendly monitorkill / pkill / killall– Terminate processesnice / renice– Adjust process priority- Monitoring and managing processes is key for system performance
▶️ Coming Up Next
Chapter 10 – Disk and Storage Management in WSL Ubuntu
Learn how to check disk space, manage partitions, and handle storage efficiently using Linux commands.
