The short answer is: **You cannot kill a zombie process because it is already dead.**
By definition, a zombie process (state `Z` in Linux) has already completed execution. It takes up no CPU or memory. The only reason it still exists is because its **parent process** hasn't read its exit status yet. Because the zombie is dead, it will ignore all signals, including `SIGTERM` (kill -15) and `SIGKILL` (kill -9).
To get rid of a zombie, you must deal with its parent. Here is how to do it step-by-step:
### Step 1: Find the Parent Process ID (PPID)
First, you need to find the ID of the process that spawned the zombie. Run the following command (replace `<zombie_PID>` with the ID of your zombie process):
```bash
ps -o ppid= -p <zombie_PID>
```
*Alternatively, you can list all zombies and their parents with: `ps -A -ostat,pid,ppid,cmd | grep -e '^[Zz]'` (The third column is the PPID).*
### Step 2: Nudge the Parent Process
Sometimes, the parent process just needs a reminder to check on its children. You can send a `SIGCHLD` signal to the parent, which tells it "one of your child processes has died, please clean it up."
```bash
kill -s SIGCHLD <PPID>
```
Check if the zombie is gone. If it is, you're done!
### Step 3: Kill the Parent Process
If the parent process is frozen, poorly programmed, or refusing to clean up the zombie, your only option is to kill the parent.
**Warning:** Make sure you know what the parent process is before doing this. Killing it might stop a service you are currently using.
First, try to kill the parent gracefully:
```bash
kill <PPID>
```
If the parent refuses to die, force kill it:
```bash
kill -9 <PPID>
```
**What happens next?**
When the parent dies, the zombie process becomes an "orphan." In Linux, orphaned processes are immediately adopted by the `init` or `systemd` process (PID 1). PID 1 is programmed to automatically clean up (reap) any zombies it adopts. The zombie will instantly disappear.
---
### A Common Mix-Up: Is it actually in "D" State?
Often, people confuse a Zombie process (`Z`) with a process in **Uninterruptible Sleep (`D` state)**.
If you run `top` or `ps aux` and the process has a **D** next to it, it is *not* a zombie. It is a living process that is stuck waiting on hardware (like a disconnected network drive, a failing hard drive, or a USB issue).
* You **cannot** kill a `D` state process with `kill -9`.
* To fix a `D` state process, you either have to restore the hardware connection it is waiting for, or **reboot the server**.