Skip to content

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

CommandDescriptionExample
topDisplays real-time CPU and memory usage of active processestop
htopEnhanced version of top (requires installation)htop
ps auxLists all running processesps aux
grepFilters process list by keywordps 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:

CommandDescriptionExample
kill PIDGracefully stops a processkill 2431
kill -9 PIDForcefully terminates a processkill -9 2431

Use kill -9 only when the regular kill command 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:

ShortcutDescription
Ctrl + CStops (terminates) the currently running process
Ctrl + ZPauses the running process and sends it to the background
Ctrl + DEnds terminal input or exits the session (useful for closing shells or ending input prompts)

You can manage background jobs using:

CommandDescription
jobsLists suspended or background processes
fg %job_numberBrings a background job to the foreground
bg %job_numberResumes 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

CommandDescriptionExample
tasklistLists all running processestasklist
Get-ProcessPowerShell command to display process detailsGet-Process
Get-Process | findstr pythonFilters process list by keyword (similar to grep)Get-Process | findstr python

Stopping a Process

CommandDescriptionExample
taskkill /PID <pid>Terminates a process by PIDtaskkill /PID 2431
taskkill /IM <name>Terminates a process by nametaskkill /IM python.exe
Stop-Process -Name <name>PowerShell command to stop a processStop-Process -Name python
Stop-Process -Id <pid>PowerShell command to stop by PIDStop-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, and kill in Linux, macOS, and WSL for real-time monitoring and control.
  • Use tasklist, taskkill, or PowerShell commands like Get-Process and Stop-Process in 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.