How to kill zombie processes on linux

Q . Sometime I type command and accidentally hit the [ENTER] key and immeditly realized that it was wrong command. How do I stop process assuming that process is not going in background? For example
cp /path/* /wrong/path

Stop or terminate Linux command process with CTRL + C

A. To stop process hit CTRL + C, for example, you entered:
$ cp -r /path/* /wrong/path

To stop the command hit CTRL+C and retype the command:
$ cp -r /path/* /correct/path

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far. add one

  • Kill Process in Linux or Terminate a Process in UNIX…
  • Disable ctrl+alt+del on Centos Linux server
  • Ubuntu Linux Disable control-alt-delete…
  • Bash Shell Scripting Disable Control-C [ CTRL+C ] Keys
  • Windows like Ctrl + Alt + Delete on MacOS App To Kill Tasks
  • Ubuntu Linux Stop a Process
  • Linux find out what process are eating all memory…
Category List of Unix and Linux commands
File Management cat
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Network Utilities dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time
Searching grep • whereis • which
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

I read that typing ‘reset’ works, even if you cant see it typing. I just use ctrl+c

./ManualManageDB.shn /user/SHARK/log_files/sms.cfg 131022

how can i stop that command, it is loading data into mysql table.

Is there a way I can stop a command without actually switching focus to the terminal window running the command? More specifically I’m trying to stop a script that switches focus to other window. It’s a script running xdotool commands and sometimes it goes wrong and needs to be stopped quickly.

Try opening a terminal and running “top”
Then press “k” and enter the procedure number.

In our everyday lives, we face this situation a lot of times when we have to exit a process forcefully – windows users would be pretty familiar with this, and the ease with which they are able to do so is very good.

Unix users have a slightly complex approach when it comes to exiting a process less gracefully. Unlike windows, you can’t just open the task manager and exit the process. Also, quite few of us are terminal lovers and so we always love the commands that would allow us using the terminal.

Another problem, or everyday scenario that a lot of us, particularly software testers, is to find something useful or finding an error information from a log. This is like a day to day necessity that a lot of us have, and it is important that you know how to use the terminal properly, because it makes this tedious job a lot easier. I have seen scenarios where a tester is made to go through a log file, which is having -like a thousand lines of log information, probably from months, and is in need to having to find some specific information in it.

So today, we’ll be looking at this two problems and how Unix gives us the command to solve these.

Now since Linux and Mac are based on Unix architecture, so a lot of the commands given are same and would do the same work on either Linux and Mac.

To terminate or exit a process in Unix, there is a very good command called the kill command.

Kill command send a signal, a specified signal to be more perfect to a process. The kill command can be executed in a number of ways, directly or from a shell script.

Using kill command from

provide you some extra feature to kill a process by process name using

. The common syntax for kill command is:

# kill [signal or option] PID

where PID is the process id of the specific process that you want to exit or terminate.

The Signal or Option can take the following values

From the behaviour above SIGTERM is the default and safest way to kill a process. SIGHUP is less secure way of killing a process as SIGTERM. SIGKILL is the most unsafe way among the above three, to kill a process which terminates a process without saving.

In order to kill a process, we need to know the Process ID of a process. A Process is an instance of a program. Every-time a program starts, automatically an unique PID is generated for that process. Every Process in Linux, have a pid. The first process that starts when Linux System is booted is – init process, hence it is assigned a value of ‘1‘ in most of the cases.

Init is the master process and can not be killed this way, which insures that the master process don’t gets killed accidentally. Init decides and allows itself to be killed, where kill is merely a request for a shutdown.

To know all the processes and correspondingly their assigned pid, run.

You can see an output like this – this is from my Mac terminal

Before we step ahead and execute a kill command, some important points to be noted:

  1. A user can kill all his process.
  2. A user can not kill another user’s process.
  3. A user can not kill processes System is using.
  4. A root user can kill System-level-process and the process of any user.

To kill a process we already gave the command above. Now let’s suppose, Skype is running on our system, with a given PID.

As per this, the PID for Skype is 10101, and so to terminate this or kill this process we’d write

Now instead of using the signal value, you can also use the Signal name to achieve the same objective.

kill -SIGTERM 10101

kill -SIGKILL 10101


To kill multiple processes at once, you just need to provide the PID’s of the process that you would like to be killed.

kill PID1,PID2,PID3
kill -9 PID1,PID2,PID3


If there is a process that has multiple childs or instances of it created, you can kill all those instances at once using the killall command

Here we don’t use the PID, but instead the process name.

killall [signal or option] processname

For example, if there are many Chrome tabs open and I want to exit all of them at once, then I would do something like

  • Topics+
    • Cloud
    • Containers
    • Desktop
    • Kernel
    • Mobile
    • Networking
    • Privacy
    • Programming
    • Security
    • Servers
    • SysAdmin
  • News
  • eBooks


  • News
  • Popular
  • Recent

How to kill zombie processes on linux

Killing Zombies!

Also known as “defunct” or “dead” process – In simple words, a Zombie process is one that is dead but is present in the system’s process table. Ideally, it should have been cleaned from the process table once it completed its job/execution but for some reason, its parent process didn’t clean it up properly after the execution.

In a just (Linux) world, a process notifies its parent process once it has completed its execution and has exited. Then the parent process would remove the process from process table. At this step, if the parent process is unable to read the process status from its child (the completed process), it won’t be able to remove the process from memory and thus the process being dead still continues to exist in the process table – hence, called a Zombie!

In order to kill a Zombie process, we need to identify it first. The following command can be used to find zombie processes:

$ ps aux | egrep “Z|defunct”

Z in the STAT column and/or [defunct] in the last (COMMAND) column of the output would identify a Zombie process.

Now practically you can’t kill a Zombie because it is already dead! What can be done is to notify its parent process explicitly so that it can retry to read the child (dead) process’s status and eventually clean them from the process table. This can be done by sending a SIGCHLD signal to the parent process. The following command can be used to find the parent process ID (PID):

Once you have the Zombie’s parent process ID, you can use the following command to send a SIGCHLD signal to the parent process:

However, if this does not help clearing out the Zombie process, you will have to kill or restart its parent process OR in case of a huge surge in Zombie processes causing or heading towards system outage, you will have no choice but to go for a system reboot. The following command can be used to kill its parent process:

Note that killing a parent process will affect all of its child processes, so a quick double check will be helpful to be safe. Alternatively, if few lying zombie processes are not consuming much CPU/Memory, it’s better to kill the parent process or reboot the system in the next scheduled system maintenance.

Nawaz is a Linux enthusiast and has been working in IT/Software for more than 7 years. He mostly works around Shell Scripting, Python and AWS. Having a knack for Automation, he believes that “every manual & repetitive task should be done meticulously to an extent that you create a need to automate it.” Nawaz can be reached via LinkedIn and email.

Today we will learn about zombie processes. In particular, we will guide you to find and kill zombie processes on your Linux / Unix operating systems.

What is a zombie process?

On Linux / Unix operating systems, a defunc process (aka zombie process) is a system process that has completed its execution, however it still show on the system process table. In other words, it’s an empty process, that is not executing any task, but still exist and has a process ID.

If there is a zombie process, there is a parent process around. And the same as in the movies, zombies do not react to normal ways of killing. On Unix / Linux it’s the same, you can’t kill the zombie, but you can kill the parent process, which will make the zombie process dissapear immediately.

Zombie processes can be found on almost any Unix / Linux operating system, and that also includes cPanel servers.

How can I list zombie processes on my system?

Zombies processes can be found by using the ps command, and piping a grep command with ‘defunc’ or ‘Z’ string in the “STAT” column.

Example: finding zombie processes using ps and grep.

Kill zombie processes

Now in order to kill the zombie process, just kill the 3572 process and it should be gone. Let’s use pstree command to fund out the parent process

The output should be something like:

This will show the pid of the of the parent of the zombie process. Now you need to kill the parent process.

All done, now you know how to find and kill zombie processes on Linux / Unix operating systems. Do you know other ways to find and kill zombie processes on Linux / Unix? Please share your knowledge with us.

If you’ve ever used the CLI utility in a Linux terminal called top, then there’s a good chance you’ve seen something called zombie processes and, if you didn’t know, wondered what those were. In this article, I’m going to demystify zombie processes and tell you how you can kill them if you see them in the wild. In the screenshot below, if any zombie processes exist on the Linux system, then the number of those zombie processes will be enumerated to the left of the word zombie on the second line from the top of the screen. In this example, there are no zombie processes resident on this CentOS 8 Linux system.

Zombie processes, otherwise referred to as defunct or dead processes, occur in a Linux system when a child process of a parent process spawned in the system is killed or exits after process execution but the parent that spawned that child process is unaware that the child is dead. Therefore, the parent process continues to list the defunct or dead child process in the system’s process table. There can be a number of reasons for this but, suffice it to say, the parent process fails to clean up the dead process and the system thinks that it is still around.

The typical function of processes in a normal Linux system is one in which child processes of a parent notify the parent when it completes execution. The parent process then cleans up the completed process’s PID (Process ID) by removing it from the process table. If the parent process is unable to read the status of its child process for any reason and the child process dies or stops functioning, then the parent process will not be able to remove the child process from resident system memory and the dead child process will continue to occupy memory space and go on existing in the process table as a Zombie (the living Dead, hence the name).

It is at this point that the Linux user must take action to remove the zombie process. But, before that can be done, the Linux user must be able to identify that process which is declared a zombie. The following Linux command can be helpful in identifying zombie processes:

Here, in this command, the ps command (processes) is used with the a, u, and x options, then the results of this process are piped out to egrep looking for the upper case letter Z or the word defunct in the output. The egrep command is an acronym for Extended Global Regular Expressions Print. It is a program which scans a specified file line by line, returning lines that contain a pattern matching a given regular expression. In this particular case, scans the output of ps aux looking for the two terms enumerated above, then sends them to the Terminal window as stdout. A Z in the STAT column or the term defunct in the last column COMMAND would identify a process as being a Zombie.

Technically a zombie process is already dead so killing this process like any other process in the Linux system is essentially nonsensical. However, what we can do instead is to inform the parent process of the zombie (child process) that the child process is dead so the parent process can take another look at it and take action to remove it as it should have been in the first place. This process can be triggered by manually sending a SIGCHLD signal to the parent process But, first, we must find the parent PID of the child PID. This can be accomplished by running the command:

Once the parent process of the zombie child process has been identified, then we can send the SIGCHLD signal to the parent process using the command:

If, after sending this signal to the parent process, no action is forthcoming to remove the zombie, then it may become necessary to manually attempt to either kill the parent process or restart the system–especially if several zombies associated with the parent process begin to grow in the system threatening to cause a system crash. The following command can be used to attempt to kill the errant parent process:

However, before taking this action, it must be stressed that a parent process may spawn more than one child process and, by killing the parent process you identify that is associated with the zombie, you may in fact remove the parent of several child processes which will be left dangling in the system without dependency support. Thus, it might be more advisable to simply reboot the system during the next maintenance cycle to fix this issue, then run top once again to see if the problem has been resolved.

In UNIX and Linux Operating System, Zombie processes also known as defunct processes, are those which are still running after the complete execution of the process but it still remains in the process table. In this tutorial, we will learn how to check and kill Zombie processes in CentOS 8.

How to find zombie/defunct processes in CentOS

To view Zombie or Defunct processes open up the terminal and use the following command:

How many Zombie Processes are running?

To view how many Zombie processes are running, you can use the following commands.

List the Process ID of Zombie Process

To list down the process ID of the Zombie processes, use the following command:

To kill the Zombie process use the following command with the process id, it will remove the Zombie process running on your server. For this use the following command.


In this tutorial, we learned how to display the Zombie process and their process IDs and how to kill them.

  • ← Do Math on Linux Command Line with expr command
  • How to install Firefox Browser on Debian 10 →

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.

I am running Bacula on a RedHat box. From time to time, the storage daemon bacula-sd stops working and becomes .

My question is, how can I kill this process? Its parent is 1, which is init, as far as I know, and I wouldn’t want to kill the init process, would I?

‘Normally’ killing this process does not work:

Help is greatly appreciated!

produces the following output:

How to kill zombie processes on linux

7 Answers 7

The only way you could remove the zombie/defunct process, would be to kill the parent. Since the parent is init (pid 1), that would also take down your system.

This pretty much leaves you with two options.

  • Manually modify the process table, eg. create a dummy process, link the defunct process as a child of the dummy, then kill them off. Quite dangerous, and you may have to manually clean up other process resources such as semaphores and file handles.
  • Reboot the system.

I’d go with the second.

Check if there was a kernel panic,

Check if the process is in “D” Unkillable sleep, where it’s in kernel mode for some syscall which has not returned yet (either kernel oops, or some other reason)–td20645581.html

How to kill zombie processes on linux

You could try restarting init:

Otherwise, I wouldn’t worry too much. It’s not running and it’s not taking any resources and it’s just there so the kernel can remember it.

If a zombie has init as its parent, then init has stopped working properly. One of the roles of init is to clean up zombies. If it doesn’t do it, noone else will. So the only solution is to reboot. If init is broken, then a reboot may fail, so I’d shut down important services, sync the filesystem then hit the power button instead.

Let’s keep the panic down, shall we? A “defunct” or “zombie” process is not a process. It is simply an entry in the process table, with a saved exit code. Thus, a zombie holds no resources, takes no CPU cycles, and uses no memory, since it is not a process. Don’t get all weird and itchy trying to “kill” zombie processes. Just like their namesakes, they can’t be killed, since they’re already dead. But unlike the brain-eating kind, they harm absolutely no-one, and won’t bite other processes.

Don’t let zombie processes eat your brain. Just ignore them.

I just noticed some zombie processes on CentOS 6.8(Final), tried to kill them but they are still there:

As you can see they are running for two months, and too if they are not harmful I would get rid of them, any alternative way to kill a Zombie?

How to kill zombie processes on linux

4 Answers 4

As mentioned by Heemayl, you cannot actually kill a zombie. It’s already [un]dead.

However, the problem you are facing looks like a problem with the git clone command. It gets stuck somehow. Probably times out or fails in some other way? It is often because of some I/O that a process gets stuck to the point where a SIGTERM and SIGINT won’t work.

To kill it, in this case, you want to use the -9 command line option. This means send the SIGKILL signal. You can actually use -KILL too.

To get a list of available signals, use the list command line option.

This shows you the numbers and names (and you’ll see that #9 says SIGKILL.)

You can’t kill a Zombie (process), it is already dead. It is just waiting for its parent process to do wait(2) and collect its exit status. It won’t take any resource on the system other than a process table entry.

You can send SIGCHLD to its parent to let it know that one of its children has terminated (i.e. request it to collect child’s exit status). This signal can be ignored (which is the default):

with the actual PID of the parent.)

Or you can kill the parent process so that init (PID 1) will inherit the zombie process and reap it properly (it’s one of init ‘s main tasks to inherit any orphan and do wait(2) regularly). But killing the parent is not recommended. Generally, creation of zombie processes indicates programming issue/issues, and you should try to fix or report that instead.

Posted by: Mohammed Semari | Published: February 27, 2018| Updated: February 27, 2018

How to kill zombie processes on linux

In this mini post I’ll show you how to find and kill all zombie processes that may exist on your Linux Systems.

First, we need to define What is the Zombie process? and Why it exists?

A process is called a zombie process or defunct process if the process has been completed, but its PID and process entry remains in the Linux process table. A process is removed from the process table when the process is completed, and its parent process reads the completed process exit status by using the wait() system call. If a parent process fails to call wait() for whatever reason, its child process will be left in the process table, becoming a zombie.

How can we discover the existence of Zombie processes on Linux Systems?

Simply by using top command, this will show the status of all processes running on your Linux System. run the following command and notice it’s output:

From the above output, I’ve 4 zombie processes that completed their tasks and didn’t exit. It’s save to kill them, but first we need to list them.

How can we get the Zombie from process list…?
Its very simple. You can find out Zombie process with the following commands:

Now, we have the PID of the four zombie processes on our Linux System, let’s go and KILL THEM ALL using kill command, go ahead and run this command:

Hooray, we killed the zombie process, let’s double check, by running any of the above command:

Oh No, The Zombie Processes still exist on our Linux box, Kill command failed to kill them WHY?

Killing zombie processes is not obvious since zombie processes are already dead.

How can we KILL the Zombie processes?

Simply, we have to kill it’s parent process. If the parent exited, the child would be orphaned and re-parented to init, which would immediately perform the wait(). In other words, they should go away once the parent process is done.

We need to find the PPID “the parent process ID” of the zombie processes using the following command and search for the zombie process PID:

In our example, the parent of the zombie process is the monit monitoring with PID 4647. Now we kill the monit process “the parent” to kill all it’s zombie processes, run the following command:

Now, we check on the existence of ant zombie processes by using top and ps commands:

Hooray, zombie process count is ZERO,now ps command check

No results found from ps command. We totally killed all our zombie processes.

Finally, There is another way to kill the zombie processes without the need for pstree command to get the parent process ID, we can get the PPID and PID of the zombie process using ps command as follow:

In this example, we only have one zombie process, as shown by ps command, the parent process id of the zombie process is 3615.

To check the top command output, run

Indeed, we have one zombie process, now we kill it’s parent to kill it, run the following command:

Before we leave this post, there are more commands you use to get the number of zombie processes on your Linux:

To Know How many Zombie process running on your server…?

Finally, I hope this mini post helped you.

AND DO NOT FORGET TO START THE MONIT PROCESS AGAIN “The one in the first example” As Monit do a good job on monitoring and starting services.