Skip to content
Home » htop on a Mac: Install It, or Use the Built-in top

htop on a Mac: Install It, or Use the Built-in top

Dark terminal card headed htop isn't preinstalled on a Mac, showing ls /usr/bin/htop returning No such file or directory, then brew install htop to install it or top to use the built-in, with a line mapping Linux top flags -p, -u and -b to the macOS -pid, -U and -l 1

Type htop on a fresh Mac and the shell answers command not found. It is not part of macOS and never has been. The interactive process viewer everyone reaches for is a separate install. macOS does ship a process monitor, top. However, that is the BSD version, and the flags a Linux habit reaches for are not the ones it understands. This page covers installing htop, using the built-in top in its place, and the specific flags that behave differently.

Where htop comes from

Nothing named htop ships in the macOS system directories. The system tree has no such binary:

$ ls /usr/bin/htop
ls: /usr/bin/htop: No such file or directory

Where it does turn up is a package-manager prefix. On a Mac that already has Homebrew’s htop, the shell resolves the name well outside the system tree:

$ command -v htop
/opt/homebrew/bin/htop
$ htop --version
htop 3.5.1

That path is the tell. Anything under /opt/homebrew, or /usr/local on an Intel Mac, came from a package manager rather than from Apple. On a Mac without Homebrew, the same htop returns command not found. Either way, it is a third-party tool you opt into. That matters before a script assumes every Mac it runs on has it.

Installing htop

Homebrew is the usual route, and one command puts it on the path:

brew install htop

After that, htop opens the full-screen viewer. You get per-core meters across the top, a scrollable process list below, and function keys along the bottom. Those keys are the draw. You sort with F6, filter with F4, and search with F3. You can also send a signal with F9 without looking up a PID first. The tree view on F5 groups child processes under their parent. That is the feature the built-in tool has no answer for.

The built-in alternative: top

Sometimes installing anything is off the table: a machine you do not control, a locked-down shell, or just a quick look. In those cases the built-in top is already there. It opens with a summary block of load average, CPU split, and memory. Below that sits a live process list that refreshes in place:

$ top

It is a capable monitor. What it is not is the Linux top. The BSD version has its own flag set and its own sort syntax. Also, for a few things Linux users expect, there is simply no equivalent. Reaching for the wrong option here is the usual reason a familiar command does nothing. If the terminal is not where you want to be at all, Activity Monitor in Applications › Utilities is the built-in graphical version of the same idea.

Flags that differ from Linux

These are the everyday mismatches between the Linux top and the one on a Mac:

What you would type on LinuxWhat macOS top wants
top -p 1234 (watch one PID)top -pid 1234 (repeat for more)
top -u alice (one user)top -U alice
top -H (show threads)no per-thread flag
top -b (batch mode)top -l 1 (one sample)
press a key to sort-o key, e.g. -o cpu

Sorting is the sharpest edge. On a Mac, -o key orders the list by one column in descending order. So -o cpu or -o mem is what you want most of the time. There is a shortcut, too. The man page documents -u on its own as “an alias equivalent to: -o cpu -O time“. In other words, it is a CPU-first view in a single letter. Note that this -u is about sorting, not filtering by user. That is exactly the trap for someone arriving from Linux.

A one-shot snapshot

The most useful non-interactive form takes a single sample and then exits. That suits a script, or a fast “what is busy right now” check:

$ top -l 1 -o cpu -n 10

-l 1 takes one logging sample instead of refreshing forever, -o cpu sorts by processor use, and -n 10 caps the output at ten processes. To trim the columns down to the ones you care about, add -stats with a list of keys:

$ top -l 1 -o cpu -n 5 -stats pid,cpu,command

That is the built-in answer to the question htop is usually opened for, and it needs nothing installed. For anything more than a glance — scrolling, searching, killing from the list — htop earns its one-line install.

Quick reference

TaskCommand
Install htopbrew install htop
Launch htophtop
Live monitor, built intop
One-shot CPU snapshottop -l 1 -o cpu -n 10
Watch one processtop -pid 1234
Filter by usertop -U alice
Sort by memorytop -o mem

htop on a Mac is one install away, and worth it for the tree view and the function keys. When you cannot install it, the built-in top does the same job. The catch is feeding it macOS flags rather than Linux ones. Three save the most confusion: -pid instead of -p, -U instead of -u for a user, and -l 1 for a single sample.

Leave a Reply

Your email address will not be published. Required fields are marked *