Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

kill Command Guide for Sending Signals to Processes

This guide helps you understand and use the kill command, the standard way to stop, pause, or otherwise signal a running process.


What is kill, and Why Use It?

The kill command sends a signal to a process — most often the request to terminate it. Its name is historical: it can do much more than kill. It can ask a process to reload its config, pause it, resume it, or tell it to reread a file. Every signal is a small message, and kill is how you deliver one, using the process ID (PID) as the address.

Why Learn kill?

  • The only way to stop a stuck program: When an app will not quit, kill is the last resort.
  • Signals are the OS’s remote control: Reload a web server without dropping connections, pause a job, resume it — all signals.
  • It is the foundation of job control: jobs, bg, and fg are built on the same idea.
  • Universal: kill works the same on every Unix-like system.

kill does not mean “destroy” — it means “send a message.” SIGTERM says “please stop”; SIGKILL says “you are being removed.”


1. Kill a Process by PID

ps aux | grep nginx     # find the PID
kill 1234               # politely ask PID 1234 to terminate
  • kill needs the process ID, which ps or pgrep provide;
  • Without a signal, kill sends SIGTERM (15) — the polite request to shut down cleanly;
  • A well-behaved process saves state and exits; a well-written service shuts down gracefully.

2. Force-Kill with SIGKILL

kill -9 1234
  • -9 sends SIGKILL — the forceful kill the kernel enforces immediately;
  • The process cannot ignore, block, or clean up after SIGKILL;
  • Use it only when SIGTERM fails — a process killed with -9 leaves temporary files and half-finished work behind;
  • The modern equivalent is kill -KILL 1234, which reads the same but is harder to mistype.

3. List Available Signals

kill -l
  • -l prints every signal the system knows, by number and name;
  • The important ones: SIGTERM (15) polite stop, SIGKILL (9) immediate stop, SIGHUP (1) reload config, SIGINT (2) interrupt (like Ctrl+C), SIGSTOP (19) pause, SIGCONT (18) resume;
  • Signal names can be used with or without the SIG prefix: -TERM, -SIGTERM, and -15 all mean the same thing.

4. Reload a Configuration with SIGHUP

kill -HUP 1234
# or
kill -1 1234
  • Many daemons — web servers, log rotators — treat SIGHUP as “reread your config and keep running”;
  • This is how you apply a config change without dropping active connections;
  • Not every program honors SIGHUP this way — check its documentation.

5. Pause and Resume with STOP and CONT

kill -STOP 1234    # freeze the process in place
kill -CONT 1234    # resume it exactly where it stopped
  • SIGSTOP suspends a process without killing it — useful for debugging or buying time;
  • A stopped process keeps its memory and open files but uses no CPU;
  • SIGCONT resumes it; bg and fg use these signals behind the scenes for shell jobs.

6. Kill Several Processes at Once

kill 1234 5678 9012
# or, with a range:
kill 100-110
  • kill accepts multiple PIDs in one command;
  • A dash creates a range of consecutive PIDs;
  • Combine with pgrep: kill $(pgrep -f firefox) stops every matching process.

Common Pitfalls

  • Reaching for -9 first: SIGKILL skips all cleanup. Try plain kill (SIGTERM) and give the process a moment; escalate to -9 only if it refuses.
  • Killing the wrong PID: Double-check with ps -p 1234 before killing — a recycled PID belongs to a different program now.
  • Expecting kill to work on zombies: A zombie (Z state in top) is already dead; its parent must reap it. kill cannot help — fix the parent instead.
  • Forgetting PID 1: kill 1 targets the init system; on most systems it is ignored, but do not experiment on production machines.

PageDescription
psFind the PIDs kill needs
pgrepLook up PIDs by name
killallKill by program name instead of PID
pkillKill by name pattern with filters
jobsShell jobs kill can also target
nohupKeep processes alive after logout

kill Cheatsheet

TaskCommand
Politely stop a processkill 1234
Force-killkill -9 1234 or kill -KILL 1234
List signalskill -l
Reload configkill -HUP 1234
Pause / resumekill -STOP 1234 / kill -CONT 1234
Kill severalkill 1234 5678 or kill 100-110
Kill by name patternkill $(pgrep -f name)