htop allows me to nicely see trees of processes within the shell. I can kill processes by pressing F9 (KILL) and then selecting which signal (e.g. 15 SIGTERM) I want to send to a job to kill.

However, this only allows me to kill one process at a time. Is there a way to kill a full tree of processes using htop?

5 Answers 5


From man htop:


Space Tag or untag a process. Commands that can operate on multiple processes, like "kill", will then apply over the list of tagged processes, instead of the currently highlighted one.

U Untag all processes (remove all tags added with the Space key).

F9, k "Kill" process: sends a signal which is selected in a menu, to one or a group of processes. If processes were tagged, sends the signal to all tagged processes. If none is tagged, sends to the currently selected process.

Not quite the answer you were looking for, but close. You can also eliminate process groups or children with kill, see:



There has been a feature for this for a long time, but it was missing from the manual until 2018: press the c key to select the currently highlighted process as well as all of its children. Then operations that apply to selected processes (such a killing using the k key) apply to the process and its children.

This isn't atomic, though. If new children are spawned between the moment you press c and the moment the kernel has killed all the processes, they won't be killed and will most likely end up being reattached to the init process. This is because htop is looping on the selected processes and killing them one by one.

I've proposed a patch to add an atomic group-killing feature to htop a while ago, but the implementation wasn't consensual enough for it to be merged. With it, it is possible to kill a whole process group atomically from htop. That's not exactly the same as killing a whole tree, but AFAIK, the kernel doesn't provide any way to kill an arbitrary tree atomically.


From the htop manpage:

F5, t Tree view: organize processes by parenthood, and layout the relations between them as a tree. Toggling the key will switch between tree and your previously selected sort view. Selecting a sort view will exit tree view.

So hit F5, and you may have to then hit 't'. That'll let you kill the entire tree.

  • 1
    This will only work if the "tree" is inevitably bound to its parent; note that htop shows thread groups as trees (in which case, the branches are not real processes). Otherwise, the orphan children will be re-parented by init, so not killed.
    – goldilocks
    Commented Feb 5, 2013 at 20:36
  • I absolutely agree, though this depends strictly on the processes involved. Killing an ssh tree session will kill underlying children procs, for example; the OP wasn't particularly specific about why he wanted to kill a whole tree.
    – Stephan
    Commented Feb 5, 2013 at 20:59

You could hijack htop's s command. In htop, pressing s invokes strace -p <the-pid-of-the-selected-process>.

Then what you could do is create a strace command that contains something like:

#! /bin/sh -
pids=$(ps -eo pid= -o ppid= |
  awk -v exclude="$PPID" -v pid="$2" '
    function descends(p) {
      if (p == exclude) return 0
      if (p == pid) return 1
      if (p <= 1) return 0
      return descends(parent[p])
    { parent[$1]=$2 }
    END {
      for (p in parent)
        if (descends(p))
         print p
if [ -z "$pids" ]; then
  echo >&2 "No process found to kill"
  echo >&2 Killing $pids
  kill $pids

And place it in some directory like ~/.htop-hijack, and call htop as:

PATH=~/.htop-hijack:$PATH htop

Then, pressing s would invoke that command instead of strace (you need to press Esc to return to the main screen afterwards).


In htop, press c to tag a process tree, then k to kill.

       c    Tag  the  current process and its children. Commands that can operate on                                                                                                                                                                                                                                                                        
            multiple processes, like "kill", will then apply over the list of tagged                                                                                                                                                                                                                                                                        
            processes, instead of the currently highlighted one.   

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .