Appearance
Process Management
Process management allows you to monitor, pause, and terminate running programs or background tasks. It’s an essential skill for simulation and development workflows — especially when a process becomes unresponsive, consumes too much CPU or memory, or runs longer than expected.
The commands and shortcuts covered here work across Linux (Ubuntu/WSL), macOS, and Windows (PowerShell/Command Prompt), with a few syntax differences noted below.
Process Management in Linux / macOS / WSL
Linux and macOS terminals share the same command set since both are UNIX-based. These commands also work identically in WSL (Windows Subsystem for Linux) when using Ubuntu or similar distributions.
Checking Active Processes
| Command | Description | Example |
|---|---|---|
top | Displays real-time CPU and memory usage of active processes | top |
htop | Enhanced version of top (requires installation) | htop |
ps aux | Lists all running processes | ps aux |
grep | Filters process list by keyword | ps aux | grep python |
Press q to exit top or htop.
Stopping a Process
Every running process has a unique PID (Process ID). To stop or kill a process, use the following commands:
| Command | Description | Example |
|---|---|---|
kill PID | Gracefully stops a process | kill 2431 |
kill -9 PID | Forcefully terminates a process | kill -9 2431 |
Use
kill -9only when the regularkillcommand doesn’t stop the process. It sends a termination signal that cannot be ignored.
Keyboard Shortcuts for Process Control
When you’re running a command or script directly in the terminal, these shortcuts are the quickest way to control processes:
| Shortcut | Description |
|---|---|
| Ctrl + C | Stops (terminates) the currently running process |
| Ctrl + Z | Pauses the running process and sends it to the background |
| Ctrl + D | Ends terminal input or exits the session (useful for closing shells or ending input prompts) |
You can manage background jobs using:
| Command | Description |
|---|---|
jobs | Lists suspended or background processes |
fg %job_number | Brings a background job to the foreground |
bg %job_number | Resumes a paused job in the background |
Process Management in Windows (PowerShell / Command Prompt)
Windows has its own set of commands for viewing and managing active processes. These can be executed from PowerShell or Command Prompt.
Checking Active Processes
| Command | Description | Example |
|---|---|---|
tasklist | Lists all running processes | tasklist |
Get-Process | PowerShell command to display process details | Get-Process |
Get-Process | findstr python | Filters process list by keyword (similar to grep) | Get-Process | findstr python |
Stopping a Process
| Command | Description | Example |
|---|---|---|
taskkill /PID <pid> | Terminates a process by PID | taskkill /PID 2431 |
taskkill /IM <name> | Terminates a process by name | taskkill /IM python.exe |
Stop-Process -Name <name> | PowerShell command to stop a process | Stop-Process -Name python |
Stop-Process -Id <pid> | PowerShell command to stop by PID | Stop-Process -Id 2431 |
For stubborn processes, use
/F(force):taskkill /F /IM python.exe
Summary
Process management is crucial for maintaining control over simulations, scripts, and background operations.
- Use
top,ps, andkillin Linux, macOS, and WSL for real-time monitoring and control. - Use
tasklist,taskkill, or PowerShell commands likeGet-ProcessandStop-Processin Windows. - Remember keyboard shortcuts: Ctrl + C to stop, Ctrl + Z to pause, and Ctrl + D to exit input or terminal sessions.
These tools help you efficiently manage processes, recover from hangs, and keep your system responsive during heavy computational workloads.