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.
