Operations 3 min read

How to Locate and Eliminate Zombie Processes with ps, grep, and kill

This guide explains how to use the ps and grep commands to identify zombie processes on Linux, shows the command syntax, interprets the output, and provides step‑by‑step instructions for terminating the zombie and its parent process if needed.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Locate and Eliminate Zombie Processes with ps, grep, and kill

Zombie processes are defunct entries that remain in the process table after their child has terminated but the parent has not yet read the exit status. They can be identified by a status code of Z or z.

Finding Zombie Processes

Run the following command to list all processes and filter for zombies: ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]' Explanation of options: -A: list all processes -o: customize output fields; here we request stat (status), ppid (parent PID), pid (process ID), and cmd (command) grep -e '^[Zz]': select lines where the status field starts with Z or z, indicating a zombie

Typical output looks like:

Z 12334 12339 /path/cmd

Terminating the Zombie Process

First try to kill the zombie directly using its PID (the third column): kill -HUP 12339 After executing, run the detection command again to verify the zombie is gone.

If the zombie persists, kill its parent process (the second column) instead: kill -HUP 12334 This forces the parent to reap the zombie.

Alternative View with top

The top command also shows a dynamic process table where zombie entries are labeled as zombie.

top output showing zombie processes
top output showing zombie processes

By following these steps you can reliably locate and clean up zombie processes on a Linux system.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxSystem AdministrationGreppskillzombie process
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.