Being a computer science student, I need to install a lot of different software on my laptop, as a different course would require a different set of applications to use. For example, my “Data Analytics and Visualization” course would require me to install R and RStudio while my “Supercomputing for Big Data” course would require me to install Scala and SBT. Another course requires me to install Elasticsearch and Kibana, or Python and Jupyter Notebook. Sometimes, I also need to install PHP and MySQL for web development.
Being a former Windows user, a solution to keep up with the installation is to download the installation package (from AppStore or the official website) and install it manually. If I want to update the version of the app, I need to download the new version and replace the old installation one by one. This is the easy way to install things but sometimes I forgot to delete the installation package or keep track of what I have installed (and which version) on my laptop.
One of my friends then told me that there is an easier way to install software (or package) using Homebrew. Homebrew is a package manager for MacOS similar to
yum in Linux. The advantage of using Homebrew, as any other package managers, is that we can manage software/package installation easily from command line. We don’t need to go to the official website of the package maintainer, download the package, and install it manually to have it in our laptop. We also don’t need to repeat this process if we want to update to the latest version.
Command Line Packages
Homebrew can be installed from terminal. To install it, run the following command.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This will install Homebrew in
Then if I want to install a specific (command-line) package, just execute
brew install <package-name>, for example, to install mysql database, just execute
brew install mysql
Homebrew has a list of more than a thousand packages maintained and updated regularly. To search if the package is available to install, run
brew search <package-name>. This command is also useful if we don’t know the (official) name of the package in Homebrew.
The followings are a list of Homebrew commands that I use the most along with their use. A more complete list of commands can be found in the documentation in its official website.
brew install <package-name>: Install a package
brew uninstall <package-name>: Uninstall a package
brew search <package-name>: Search a package. Also useful if we don’t know what is the (official) name of the package.
brew list: List all installed packages. This is useful to keep track of all package installation, for example, when we want to remove the package that we don’t need anymore.
brew outdated: List all outdated packages.
brew doctor: Check the installation of brew and check for possible installation problems.
brew update: Update Homebrew to the latest version, along with the package definitions. I run this command (almost) everytime when I open terminal since I want to keep Homebrew always updated.
brew upgrade <package-name>: Upgrade an outdated package. If no
is given, then upgrade all outdated packages. This is useful to keep the packages updated to the latest version.
brew cleanup: Delete old downloads from the Homebrew download-cache.
The commands above work for packages that are mostly run in command line, such as
r, or even
wget. So basically software without graphical user interface.
An extension of Homebrew, called Homebrew-Cask, brings the simplicity to install packages with GUI, like Google Chrome, Spotify, RStudio, MySQL Workbench, from command line similar to the installation above.
To get Homebrew-Cask, run
brew tap caskroom/cask
This will download a list of GUI packages (and additional information) that can be installed via Homebrew.
The commands above also works with Homebrew-Cask, with every command starts with brew cask. So if we want to install, for example, Spotify, just run
brew cask install spotify. If we don’t know the name of the package, for example, of MySQL Workbench, just run
brew cask search mysql to list all available GUI packages related to MySQL (from there, we can see that the package name for MySQL Workbench is
mysqlworkbench). Similarly, to list all outdated packages, run
brew cask outdated. And if we want to remove a package that we don’t need anymore, just
brew cask uninstall it.
There is no need again to download the installer for a software, drag-and-drop to Applications folder, and delete the installer every time we want to install or update a software.
For me, it’s also easier to keep track of the installed software, remove unused software, and keep my Downloads directory clean from package installer.
(This article was originally posted on Medium with title Keep Track and Keep Clean of My Software Installation in Macbook Using Homebrew. I will post some of my articles on Medium to this blog and vice versa)