htop is a fantastic commandline tool for managing your running processes. I usually find it a lot more convenient than messing around with GUI-based task managers.
Especially on my Mac, where as a former Windows kid, my brain is completely incapable of remembering that the Mac’s version of Task Manager is called the Activity Monitor.
htop looks cooler anyway. Honestly I feel like a badass just for having this thing open.
On Debian-based Linux distros,
apt-get install htop On a mac, if you have homebrew installed simply
brew install htop.
Besides just making me feel good about myself, it’s very functional. Even though it’s a commandline-based application, you actually still can click around with your mouse if you choose.
Let me explain the Gif above broadly.
The upper section of the
htop display output gives a summary of the system resources being consumed. I took this Gif from htop running on my mac, which has 4 cores. You can see how each of the cores is perfoming, along with the amount of Memory [MEM] being consumed and Swap Memory [Swp]. To the right of that, all the tasks running, number of threads, kernal threads, and number of proceses running (if you just see 1 running, that process is
htop itself). Also displays load average, and how long the computer has been on (uptime).
In the middle section, we see information about each process.
PID is the Process ID.
USER is which user the process is running under.
PRI describes the priority number for that process for CPU time. The lower the number, the higher the priority. Can be affected by the “nice” number.
NI is the “nice” number for that process. A user can manipulate this number with the
nicecommand to affect the priority of a process. Niceness values range from -20 (the highest priority) to 19 (the lowest). Only a superuser can give a lower nice value to a process.
VIRT describes the virtual memory. It’s the total memory that process is using (shared memory, physical memory in RAM, swap memory, disk memory).
RES only displays physical memory in RAM is being used.
S describes the status of the process. R means it’s running, S means it’s sleeping. In my case, htop apparently can’t determine the status of my processes, so it returned a ‘?’ I suspect it has something to do with me running this on a Mac instead of Linux.
CPU%, MEM%, and TIME are pretty straight forward.
It’s a menu! Feel free to click on any of this, or you can use the F keys if that’s not in your wheelhouse. Let’s run through it:
Help Fairly what this does, n’est pas?
Setup For the sake of brevity, not going into this, but I would highly suggest you take a look in here. The User Interface of
htop is much more customizable than it would appear. You can customize color, which info columns htop displays and doesn’t display (there are more than I’ve listed), and what information is displayed (or not) in different parts of the htop’s display.
Search Incrementally search for a process name using provided string.
Filter Filter out all other process except those matching provided string.
Tree Toggle tree view. AKA, “Hey process, who’s child are you?”
SortBy Choose which column to sort processes by. You can sort on any column by simply clicking on it.
Nice+ Increase the nice value of selected process. Unless that process is a root process.
Nice- Decrease the nice value of a selected process. Only root (or a superuser) can do this.
Kill Send a terminate signal to selected process.
Quit Bye bye.
my favorite htop shortcuts
\– Filter processes by string.
p– Toggle program names instead of paths.
t- Toggle tree view. Very cool.
+ / -expand/collapse tree branch.
u– Show process of a single user.
I– Invert sort order.
<space>– Tag a process
k– Kill selected process.
h– Show help screen.
q– Quit htop.
htop is a killer application, and I wish I had started using it sooner.