I'm using htop to interactively monitor my processes.

However, sometimes a few processes get "in the way" and I would like to filter them out.

Unfortunately, it seems that htop's built in filter (e.g. F4) only allows me to define a positive filter (only matches will be shown), and not negative filters (all but matches are shown).

Finally, I haven't found any documentation about the actual syntax of the search-string (regexes don't seem to work).

  • AFAIK is not possible. Any good reason to not use top? You can do it easily with it. – sebelk Sep 24 '15 at 13:47
  • FWIW htop filtering should gain regex filtering soon, there is a complete though still unmerged pull-request on GitHub. github.com/hishamhm/htop/pull/428 – Richard Michael Jan 9 '17 at 20:53

I don't know if it's doable with htop but if using another top implementation is an option, with the top implementation in procps on Linux (generally the default implementation there), from within top, you can

  1. enter o (or O for case sensitive matching)
  2. enter !COMMAND=notwanted (or !USER=unwanted)

to filter out the processes whose name (or command line after pressing c) contains notwanted (or whose username contains unwanted). Enter = to remove all the filters.

You can filter on any of the fields you want, but only when they are displayed. For instance, to exclude kernel tasks, you can ask for the CODE column to be displayed (with f) and then filter on CODE>0 (with o).

Note that the default interface of that top implementation may look cruder than that of htop, but it has actually quite a lot more features (and you can configure it with colour and extra information if need be).


Do not know of a direct way with htop

However you might be able to use the negating abilities of pgrep and feed a pid list to htop

Something like

htop -p "$(pgrep -vfd, 'java|python')"

This has the obvious disadvantage of not accounting for processes that start after htop starts running

  • 1
    good idea, but what i really want to do is filter out "garbage" processes when I see them; so your solution is not really "interactive" in that sense... – umläute Sep 24 '15 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.