Mission 14 of 30

Process Management

Identify and stop only a practice process you started.

View processes, start harmless background jobs, and stop only the jobs you created.

45–55 min Week 2 · Search, text, permissions, processes Ubuntu terminal
Your outcome: You can stop a runaway practice command without panicking.
Practice inside ~/linux-practice. Check your setup before you begin. Prerequisite: Ownership and Groups Without Fear .

What you’ll practice

  • Use ps and pgrep
  • Manage jobs
  • Send termination signals carefully

The mental model

  • A process is a running program.
  • PID means process ID.
  • Kill only processes you understand.

Try it in your terminal

View processes

Read-only system view

Shows current and system processes.

Run from ~/linux-practice

ps
ps aux | head -15
pgrep -l bash

Create and stop a practice job

Caution

Starts one harmless background process, captures its exact PID with $!, then stops and waits for that same process. This remains deterministic even when other jobs already exist.

Run from ~/linux-practice

cd ~/linux-practice
sleep 100 &
practice_pid=$!
echo "Started practice PID: $practice_pid"
jobs -l
kill "$practice_pid"
wait "$practice_pid" 2>/dev/null || true
jobs -l

Broad process killing examples

Caution

Useful but broad. Prefer job number or exact PID while learning.

Run from ~/linux-practice

killall sleep
pkill -f 'sleep 200'

Put it into practice

  1. Start one sleep job, list it, stop it, and confirm it is gone.

Check your result

The practice process disappears while unrelated processes remain.

Common mistakes

  • You see a process hanging and immediately type `kill -9 1234`. That's the nuclear option. It works, but it doesn't give the program a chance to clean up. Try `kill 1234` first — that sends SIGTERM, a polite request to stop. Most programs respond. If they don't after ten seconds, then reach for -9.
  • You run `pkill -f 'python'` to stop one script and accidentally kill every matching Python process you have permission to signal. Broad kill patterns are dangerous. Capture the process ID with `$!` when starting a background job, then signal that exact PID.

Check your understanding

Explain these in your own words. If you’re unsure, revisit the examples before moving on.

  1. What is a PID?
  2. Why should you avoid broad pkill patterns as a beginner?

Your practice, your pace

Loading saved progress…

Discussion

Continue the conversation about this guide. Loading comments connects to GitHub Discussions through giscus.

Open community discussions on GitHub

Check before you copy

This command needs care. Read its context, confirm the target and location, and keep a recovery path.

Copying does not run a command.