In the Unix/Linux command line environment, exploring the running processes is accomplished chiefly by two programs. top gives you a real-time list of running processes which updates periodically showing the most active processes at the top (hence the name.) ps takes a snapshot of the running processes and dumps them to the command line for you. Both of these methods work well, but a program called htop brings a little bit more sanity and convenience to the situation.
htop is ‘an interactive process-viewer for linux.’ It runs on the command line in real time like top does, but it utilizes ncurses and allows you to browse and interact with the processes. htop also features a colored interface making process management easier and more visually appealing.
htop has easy-to-read resource meters at the top of the interface which make it easy to survey the status of your system at a quick glance. The CPU meter shows you your CPU usage in a way that makes sense to humans. Where top breaks the CPU usage into several different categories, htop combines them into a simple collected usage meter. It is certainly useful to get the very specific CPU usage statistics that top offers, but most people don’t need this much information and are often confused by it. htop does, however, provide some of this information by dividing the meter into different colored sections. Blue for low priority processes, green for normal processes, and red for kernel processes. It also provides the standard CPU load averages, which is another very common representation of CPU load in Unix. htop provides resource meters for memory and swap usage as well. The memory meter is also color coded. Refer to the help section for more specifics about the color codes.
htop allows you to scroll through the list of processes either with the up/down keys, or the page-up/page-down keys. You can specify which attribute you want htop to sort the processes by (e.g. CPU%, Memory Usage, etc.) You can toggle a tree-style display showing you which processes were spawned by which other processes. You can even increase or decrease the nice value of any process. (The nice value is the priority level that the process will receive within the kernel’s scheduler. Simply put, the lower the nice value, the more critical the process and the more CPU time it will be given. ‘Nicer’ processes with a higher nice value will yield to more critical processes and will receive less CPU time. More information here.) Finally, if you’re using htop in a windowed environment with a mouse, you can use the mouse to select processes and options.
Another of the more interesting features of htop is the ability to tag multiple processes and then perform a single action on all tagged processes. So, for example, if you need to kill a group of several processes, you can tag all of the processes in the list with the space bar and then using the “F9 Kill” option. All of the tagged processes would then be killed. htop is a convenient, easy-to-use, and feature-rich replacement for top on your Linux system. It can be installed easily under Ubuntu with the following command:
sudo apt-get install htop
It can also be downloaded directly from the project website at http://htop.sourceforge.net.
cpu usage, htop, linux, memory usage, processes, ps, top unix