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.
