Intermediate · 7 min · practise every command in the built-in terminal

Killing Processes

kill — Send signal to process

kill PID                  # Send SIGTERM (graceful stop)
kill -9 PID               # Send SIGKILL (force kill)
kill -SIGTERM PID         # Same as kill PID
kill -l                   # List all signals

Common signals

SignalNumberMeaning
SIGTERM15Graceful shutdown (default)
SIGKILL9Force kill (can't be caught)
SIGHUP1Reload config (for daemons)
SIGSTOP19Pause process
SIGCONT18Resume process

killall and pkill

killall nginx             # Kill all processes named exactly nginx
pkill -u student          # Kill all processes by user student
pkill -f "sleep 300"      # Match anywhere in the full command line

Best practice

Always try SIGTERM first:

kill PID          # Try graceful shutdown first
sleep 5
kill -9 PID       # Force kill if still running

Keyboard shortcuts

  • Ctrl+C — Send SIGINT to foreground process
  • Ctrl+Z — Send SIGSTOP (pause)
  • Ctrl+\ — Send SIGQUIT

Practice tasks

  1. Start 'sleep 300' in the background, find its PID, then kill it
  2. Force-kill a background process with SIGKILL
  3. List all available kill signals

Commands in this lesson

Processes