Linux

Chapter 9: Managing Processes in WSL Ubuntu

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 users
  • u โ€“ Display user/owner
  • x โ€“ 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 โ€“ Quit
  • k โ€“ Kill process by PID
  • h โ€“ 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 processes
  • top โ€“ Real-time process monitor
  • htop โ€“ Interactive, user-friendly monitor
  • kill / pkill / killall โ€“ Terminate processes
  • nice / 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.

Leave a Reply

Your email address will not be published. Required fields are marked *