htop is an interactive system-monitor, but also a process-viewer, process-manager, strace tool and more. Sysadmins may opt to use htop in cases where Unix top does not provide enough information about system processes. htop uses a cursor-controlled interface for sending signals to processes. Just one example where this comes in handy: you don’t have to type in PIDs, simply select one or more processes using your mouse or other input device.
Although similar to top, htop also allows you to scroll vertically and horizontally, so you can see all the processes running on the system as well as viewing them as a process tree. Below is a screenshot of htop, taken from the StackLinux VPS which hosts this blog…
How to customize htop
Now the fun part! With htop open, you can use your mouse or touchpad to navigate. Start, by clicking Setup (bottom left) or by pressing F2 or shift + s. This will open the following screen…
Just about all of us use top and htop, however, more often than not, we don’t tweak to our liking. (Also read: how to customize top command and atop for Linux server performance analysis, here’s how). From the above screen you can tweak many settings. These settings are then saved to $HOME/.config/htop/htoprc
A copy of my htop config file:
(Feel free to backup and replace, then tweak some more.)
# Beware! This file is rewritten by htop when settings are changed in the interface. # The parser is also very primitive, and not human-friendly. fields=50 0 48 17 18 38 39 40 2 46 47 49 1 sort_key=111 sort_direction=1 hide_threads=1 hide_kernel_threads=1 hide_userland_threads=1 shadow_other_users=0 show_thread_names=0 show_program_path=1 highlight_base_name=0 highlight_megabytes=0 highlight_threads=0 tree_view=1 header_margin=1 detailed_cpu_time=1 cpu_count_from_zero=1 update_process_names=0 account_guest_in_cpu_meter=0 color_scheme=6 delay=15 left_meters=CPU AllCPUs left_meter_modes=2 1 right_meters=Blank Clock Uptime LoadAverage Tasks Swap Memory right_meter_modes=2 2 2 2 2 2 2
htop tweaks made with Sysadmins in mind
- Added detailed CPU usage line at the very top (System/IO-wait/Hard-IRQ/Soft-IRQ/Steal/Guest).
- hid userland process threads. (Ever open htop and without scrolling the only processes visible are MySQL threads? This solves that. Optional)
- Added NLWP column. NLWP = Number of threads in a process. (Eg. MySql) Useful when the above change is made.
- Added detailed memory usage line. (mem/used/buffers/cache)
- Change process lists to tree view.
- Changed CPU count to start from 0.
- Change CPU cores from 2, to 1 column. (may need more for high # of cores)
Here’s a visual comparison. My tweaked config on the left and default htop on the right. (full sized image here):
This is a start, feel free to share your custom htop config. Also read: htop and top alternatives: Glances, nmon.