Skip to main content
Let’s start controlling processes. This guide shows how to stop, resume, and terminate processes by sending signals, and how to manage foreground and background jobs using the shell and interactive tools.
A dark presentation slide titled "Demo: Managing Processes and Jobs." On the right is a blue line-art icon of a gear rising from waves with an upward arrow pointing to a stacked database cylinder.
The goal is to become comfortable running and managing tasks so you can control long-running commands, recover a suspended job, or terminate misbehaving processes.

Starting and controlling jobs

A shell job can run in the foreground or background. Foreground jobs attach to the terminal and block it, while background jobs run asynchronously. Common job-control actions: Tip: Use job IDs (%1, %2, …) when using fg/bg. Use jobs -l to map job IDs to PIDs.
Use jobs -l when you need the PID to send signals (for example with kill). Job IDs (like %1) are shell-local; PIDs are system-wide.
Example interactive session demonstrating these actions:

Sending signals with kill

Processes respond to signals (e.g., to stop, continue, or terminate). Use kill to send a signal to a PID.
  • kill <pid> sends SIGTERM (15) by default — a polite request to terminate.
  • kill -9 <pid> sends SIGKILL (9) — forces immediate termination; cannot be caught or ignored.
  • kill -l lists signal names/numbers available on the system.
Common signals: Example: listing signals and using kill:
Use kill -9 (SIGKILL) only when necessary — it prevents the process from cleaning up temporary files or gracefully closing resources. Try kill (SIGTERM) first.
For more detail, see the kill manual: man 1 kill.

Killing multiple processes by name

To send a signal to all processes that match a command name, use killall <name>. This sends the default signal (SIGTERM) to every matching process name. Example:
After killall sleep, all running sleep processes are terminated.

Using top to send signals interactively

Interactive process viewers like top let you send signals without leaving the tool.
  • While top is running, press k to prompt for a PID and a signal number or name.
  • Enter the PID, then the signal (e.g., 9 or SIGKILL) to send it.
Example top snapshot (when k is used you are prompted for a PID and a signal):
Enter the PID to signal and the signal number/name when prompted.

Quick reference

Summary

  • Use shell job control (Ctrl+Z, fg, bg, jobs) to pause and resume tasks without killing them.
  • Prefer kill <pid> (SIGTERM) so processes can terminate gracefully; use kill -9 (SIGKILL) as a last resort.
  • Use killall to target processes by name when appropriate.
  • Interactive tools like top provide convenient ways to inspect processes and send signals.
  • For more details, see the bash job control documentation and the kill and top man pages:

Watch Video