Homebrew is a package manager for Mac OS and Linux. You can find more details in http://brew.sh . You can install and uninstall software that you need easily from Command Line Interface(CLI).
There are more than 8500 packages and casks(GUI installation packages) in Homebrew.
Homebrew Cask is the installation and management of GUI macOS applications such as Atom and Google Chrome.
I also posted Chocolatey Package Manager for Windows. Reach out from the following link.
Before installing Homebrew
Firstly, the command-line tools for Xcode should be installed. you can install it by running the following command in a Terminal window.
xcode-select –installIf you already installed Xcode, you can check for softwareupdates.
softwareupdate --listor you can directly try to update Xcode with the following code
softwareupdate --install xcode-selectInstalling Homebrew
Installing Homebrew, in a Terminal window, copy-paste the following command, and press Enter
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"Checking Homebrew
brew --versionChecking Homebrew system
Check your system for potential problems with following command.
brew doctorUpdating Homebrew
If you want to ensure the newest version of Homebrew, run the following command in a Terminal window.
brew updateInstalling package
Let’s say that you need to use a no sql database (Redis or Mongo, etc.)
brew install redisbrew install mongodbbrew install nodeUninstalling package
If you want to uninstall a package, there are 3 different usages.
If –force is passed, and there are multiple versions of formula installed, delete all installed versions.
brew rm redisbrew remove nodebrew uninstall redisbrew uninstall nodeReinstalling package
If you want to reinstall a package again, run the following command in a Terminal window.
brew reinstall redisbrew reinstall mongodbbrew reinstall nodeListing packages
If you want to list all packages installed, then run the following command.
brew listbrew lslisting in a single column
brew ls -1Lising in a long format
brew ls -lSearching packages
Search for text in the given package manager's list.
List all locally available formulae (including tapped ones)
brew searchList all locally available formulae with description
brew search --desc ''Learning count of packages available in local
brew search --desc '' | wc -lLet's search for java jdk package. Following code will list packages(Formulaes) and casks(GUI packages)
brew search jdksearching only in casks
brew search --casks jdksearching only in formulaes
brew search --formulae jdkHomebrew Cask (GUI installation packages)
Installing Cask
brew cask install atombrew cask install google-chromeor we can install two or more packages in a single line as below.
brew cask install atom google-chromeUninstalling Cask
brew cask uninstall atombrew cask remove atombrew cask rm atomListing casks
Below two commands are depreciated in Homebrew latest version.
brew cask listbrew cask lsUse the following command instead of any of above commands.
brew list --caskLearning Cask Information
Display information about cask package.
brew cask info adoptopenjdkHomebrew Taps (Third-Party Repositories)
brew tap adds more repositories to the list of formulae that brew tracks.
Listing currently tapped repositories
homebrew/core is default repository center but other added manually.
$ brew tap
adoptopenjdk/openjdk
caskroom/fonts
homebrew/cask
homebrew/cask-fonts
homebrew/coreAdding new tap
Assume that we need to install Java JDK, so i search it firstly.
$ brew search jdk
==> Formulae
openjdk
openjdk@11
==> Casks
adoptopenjdk
jdk-mission-control
oracle-jdk
oracle-jdk-javadoc
sapmachine-jdklet's say we prefer adoptopenjdk cask, if we want to learn more information about this cask, run the following command
$ brew cask info adoptopenjdk
adoptopenjdk: 14.0.1,7
https://adoptopenjdk.net/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/adoptopenjdk.rb
==> Name
AdoptOpenJDK Java Development Kit
==> Artifacts
jdk-14.0.1+7 -> /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk (Generic Artifact)
==> Caveats
More versions are available in the AdoptOpenJDK tap:
  https://github.com/AdoptOpenJDK/homebrew-openjdk
  brew tap adoptopenjdk/openjdkso we install adoptopenjdk, we will have 14.0.1,7 in the system. But, output of terminal says that
More versions are available in the AdoptOpenJDK tap:
https://github.com/AdoptOpenJDK/homebrew-openjdk
brew tap adoptopenjdk/openjdk
brew tap adoptopenjdk/openjdkSo what happened after adding new tap(Third-party repository in Homebrew). Run the following code one more time. As shown in terminal, there are more casks related with adoptopenjdk cask
$ brew search jdk
==> Formulae
openjdk                                                                              openjdk@11
==> Casks
adoptopenjdk
adoptopenjdk12
adoptopenjdk13-openj9
adoptopenjdk14-openj9-jre-large
adoptopenjdk9
adoptopenjdk10
adoptopenjdk12-jre
adoptopenjdk13-openj9-jre
adoptopenjdk14-openj9-large
jdk-mission-control
adoptopenjdk11
adoptopenjdk12-openj9
adoptopenjdk13-openj9-jre-large
adoptopenjdk8
oracle-jdk
adoptopenjdk11-jre
adoptopenjdk12-openj9-jre
adoptopenjdk13-openj9-large
adoptopenjdk8-jre
oracle-jdk-javadoc
adoptopenjdk11-openj9
adoptopenjdk12-openj9-jre-large
adoptopenjdk14
adoptopenjdk8-openj9
sapmachine-jdk
adoptopenjdk11-openj9-jre
adoptopenjdk12-openj9-large
adoptopenjdk14-jre
adoptopenjdk8-openj9-jre
adoptopenjdk11-openj9-jre-large
adoptopenjdk13
adoptopenjdk14-openj9
adoptopenjdk8-openj9-jre-large
adoptopenjdk11-openj9-large
adoptopenjdk13-jre
adoptopenjdk14-openj9-jre
adoptopenjdk8-openj9-large
As you can see above output of terminal, we can install adoptopenjdk12 or adoptopenjdk13 or adoptopenjdk8, etc
Ok let's see results, I will install default adoptopenjdk cask package
brew cask install adoptopenjdk$ java --version
openjdk 14.0.1 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode, sharing)As you can see default adoptopenjdk is latest Java version (this time, it was 14.0.1).
I will install adoptopenjdk10
brew cask install adoptopenjdk10$ java --version
openjdk 14.0.1 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode, sharing)wait a minute, Java version is still 14.0.1 🙂
So I visited adoptopendjk GitHub repository and it says that we need to add the below function in your ~/.bashrc or ~/.zshrc
jdk() {
        version=$1
        export JAVA_HOME=$(/usr/libexec/java_home -v"$version");
        java -version
 }and run the following code to source
source ~/.zshrcor
source ~/.bashrcWe can change version like below
$  jdk 1.8$  jdk 9$  jdk 11$  jdk 13Removing tap
brew untap adoptopenjdk/openjdkAfter adding a new tap, you will
Opening Homepage
Open Homebrew's own homepage in a browser.
brew homeIf you want to open a package's homepage in a browser, then use following command.
brew home nodePackage Information
Display information about package.
brew info nodebrew info openjdkDetailed Information brew CLI
man brew