Skip to content

[MacOS] Use "brew" Command To Install Package On Terminal

Last Updated on 2021-09-04 by Clay

If you want to install some packages or open-source tool on MacOS, you can use brew command on Terminal. brew also known as Homebrew, is a well-known package management tool on Mac. We can download, search, and manage packages via this tool.

It's very convenient.

In below, I will introduce how to use brew command to install a package.


How To Use Homebrew

(Note: The following commands are all executed on the terminal)


Enable Homebrew Commands

First, we need to use the following command to install Homebrew in our computer.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"


Search A Package

We can use brew search [TEXT|/REGEX/] to search a package and confirm the package can installed by Homebrew. (brew search supports regular expressions)

For example, I want to check how can I use Homebrew to install the top command (A command to view system resources):

brew search top

Output:

Yes, I can do it.


Install The Package

You can use brew install FORMULA... to install the packages, take htop for example:

brew install htop


Update The Package

If you want to update a existed package, just use brew upgrade [FORMULA...].

brew upgrade htop


View Package Info

If you want to check the information of package, you can use brew info [FORMULA...].

brew info htop


Check All Of Packages

You can use brew list [FORMULA...] to check all the package that exist in your environment.

brew list

Output:

As you can see, not much packages in my environment.


Uninstall The Package

You can use uninstall FORMULA... to uninstall the package.

brew uninstall htop


Update Homebrew

brew update


Delete Old Homebrew Package

Sometimes, we no longer use the old version of the package, but the old version of the package still exists in the computer to occupy a place, at this time we can use the following command to clean up:

brew cleanup

References


Read More

Leave a Reply