← Back to Bash Course | Chapter 10: Text Processing Tools | Lesson 6 of 12

kill

In this page:

  1. kill

kill

kill sends a signal to a process, most commonly SIGTERM (the default) to ask it to terminate gracefully, or SIGKILL (kill -9) to force it to stop immediately. You target a process by its PID. Scripts use kill to stop background jobs they started, such as a server process spun up for testing.

Warning: kill -9 (SIGKILL) cannot be caught or ignored by the process, so it never gets a chance to clean up before exiting.

Example: kill

bash
#!/bin/bash
sleep 30 &
pid=$!
echo "Started process $pid"

kill "$pid"
echo "Sent termination signal to $pid"
🔒

Chapter Quiz — Complete all 12 topics to unlock

0/12 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.