Linux: Monitor Processes, htop
This page is a tutorial on the Linux process monitoring tool htop
. “htop” is a improved tool over the classic top
.
〔see Linux: Monitor Processes: top〕
htop lists ALL threads, not just processs, and provides easier way to let you sort, search, mark, kill, processes.
Install it, by sudo apt-get install htop
.
Start it by htop -d 50
for refresh every 5 second. To refresh manually, press Ctrl+l.
Read manual page by man htop
or summary by htop --help
.
Basic keys:
- PageUp, PageDown → scroll screen up/down.
- ↑, ↓ → move cursor.
- ←, → → scroll sideways.
- F10 or q → Quit
- F1 or h → goto help screen. q to exit help.
View
- M → Sort by memory usage.
- P → Sort by processor usage.
- T → Sort by time.
- F6 or > → Select field for sorting. The sort field is indicated by a highlight in the header.
- F4 or I → Invert sort order.
- F5 or t → Tree view toggle. Press + or - to expand/collapse subtree.
Show/Hide
- u → Show only processes owned by a specified user.
- K → Show/hide kernel threads.
- H → Show/hide user threads.
Search Processes
- F3 or / → Incremental process search by name.
- Type number to start incremental search on PID
Mark Processes
- Space → mark a process. (you can kill all marked processes later)
- U → unmark all.
Actions
- F9 or k → Send kill or other signal to current/marked process. (It'll show a menu. SIGTERM (15) is normal quit. SIGKILL (9) is force quit. SIGHUP (1) is usually reread config file.)
- F7 or ] → Increase selected process priority.
- F8 or [ → Decrease selected process priority.
Misc
- s → Trace process system calls: if strace(1) is installed, pressing this key will attach it to the currently selected process, presenting a live update of system calls issued by the process.
- l → Display open files for a process
- F2 or S → Setup screen. There you can configure meters displayed on the top side of the screen, as well as set various display options, choose among color schemes and select the layout of the displayed columns.
- a → (on multiprocessor machines) Set CPU affinity: mark which CPUs a process is allowed to use.
- F → “Follow” process: if the sort order causes the currently selected process to move in the list, make the selection bar follow it. This is useful for monitoring a process: this way, you can keep a process always visible on screen. When a movement key is used, “follow” loses effect.
- Ctrl+l → Refresh: redraw screen and recalculate values.
Color Threads, Hide Threads
htop will show all threads, not just process.
Set htop to color threads. Press S to setup. Use arrow keys to navigate.
Usually you don't care about thread. So you can just hide them both.
- H → Show/hide user threads.
- K → Show/hide kernel threads.