Back to DevOps Series

Process Management in WSL/Linux :

1. View Running Processes

Loading...
All processes:
Loading...
Process tree:
Loading...
Live process view:
Loading...

2. Find a Process

Loading...
Example:
Loading...

3. Process ID (PID)

Every running process has a PID.
Loading...
Example:
Loading...

4. Start a Process in Background

A command normally runs in the foreground, meaning the terminal waits until it finishes.
Adding & runs the command in the background, so you can continue using the terminal.
Loading...
Example:
Loading...
Here, sleep 100 waits for 100 seconds, but because of &, it runs in the background and the terminal is immediately available for other commands.
 
The process runs in the background, but its output may still appear in the terminal.
The process runs in the background, but its output may still appear in the terminal.
Multiple commands on one line :
Multiple commands on one line :
 
Check background jobs:
Loading...
Example output:
Loading...
  • [1] → Job ID
  • Running → Current status
  • sleep 100 → Background command
Important: & runs the process in the background of the current shell. It is still associated with that terminal session.
 
 
  • To see the Pid of running job :
  • Use this : jobs -l

5. Move Process to Background

Stop a running process temporarily:
Loading...
Continue it in background:
Loading...

Ctrl+Z and bg — Pausing and Resuming a Job

  • A simple example to demonstrate how a running process can be paused with Ctrl+Z and resumed in the background using bg.
Example :
Example :

6. Bring Process to Foreground

Loading...
Specific job:
Loading...
 
Example for fg :
Example for fg :

7. Kill a Process

Using PID:
Loading...
Force kill:
Loading...

Faster way for all stopped jobs

Loading...
Using process name:
Loading...

  • kill %1 → specific job
  • kill 4674 → specific process/PID
  • pkill a → all matching processes named a
 

8. Check Process Status

Loading...
Example:
Loading...

9. Run Process Even After Terminal Closes

Loading...
Example:
Loading...

10. Useful Shortcuts

Command
Purpose
ps aux
List all processes
top
Live process monitoring
pgrep
Find PID
jobs
Show shell jobs
bg
Run stopped job in background
fg
Bring job to foreground
kill PID
Terminate process
kill -9 PID
Force terminate
pkill name
Kill by process name
nohup command &
Keep process running after terminal closes

Key Point

Foreground → Background:
Ctrl + Z → bg
Background → Foreground:
fg
Terminate:
kill <PID>