What is a Zombie process in Linux?

When logging into your Ubuntu Server via SSH, you might see a message stating, "There is 1 zombie process." Don't panic. It is just a system notification. Here is what it means and how to handle it.

What is a Zombie Process in Linux?

On Linux and Unix-based operating systems, a zombie is a process that has finished running but still has an entry in the process table. The child process has died, but the system hasn't fully cleared it out yet.

When a normal process ends, the system frees up its memory and resources. The process's entry stays in the table so the process that started it (the parent) can read its exit status. The parent receives a SIGCHLD signal indicating the child has died. Usually, the parent handles this by executing a wait system call, which reads the exit status and removes the zombie.

This lingering entry is actually useful. For example, it ensures the system doesn't immediately reassign the exact same process ID to a newly created process. If a parent process gets stuck or ignores the SIGCHLD signal, the zombie gets left behind in the process table.

How to Find and Remove Zombie Processes

To track down the zombie, run the command below. It will search your process list and display the zombie along with its process ID (PID).

ps axo stat,ppid,pid,comm | grep -w defunct

To clear it, use the kill command. Just replace <PID> with the process ID displayed in your terminal.

sudo kill -9 <PID>

That's it, folks. You have officially killed a zombie :(

Thank you for reading.

I'm Feeling Lucky
Darryl Dias

Written by Darryl Dias

The AI guy and founder of Caprycon, building AI-powered tools, exploring emerging technologies, and sharing insights from the world of artificial intelligence