Here are some useful tips when using “htop”.
Question 1: Why does “htop” show more process than “ps”?
By default, htop lists each thread of a process separately, while ps doesn’t. To turn off the display of threads, press H, or use the “Setup / Display options” menu, “Hide userland threads”. This puts the following line in your ~/.htoprc or ~/.config/htop/htoprc (you can alternatively put it there manually):
In the first line of the htop display, there’s a line like “Tasks: 377, 842 thr, 161 kthr; 2 running”. This shows the total number of processes, userland threads, kernel threads, and threads in a runnable state. The numbers don’t change when you filter the display, but the indications “thr” and “kthr” disappear when you turn off the inclusion of user/kernel threads respectively.
When you see multiple processes that have all characteristics in common except the PID and CPU-related fields (NIce value, CPU%, TIME+, …), it’s highly likely that they’re threads in the same process.
Question 2: How to read htop output?
The following is the detailed column meanings of htop. To get help in htop, hit the “h” key, then the UI will give you a shortcut keys map. Such as “H” to “hide/display user process threads”, “u” to “show processes of a single user” and etc.
PID – It describes the Process ID number.