Installing homebrew

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Updating homebrew

$ brew update

Upgrading homebrew

$ brew upgrade

Upgrading cask

Below will not update casks that do not have versioning information (version :latest) or applications that have a built-in upgrade mechanism (auto_updates true). Run the upgrade command with the --greedy flag

$ brew cask upgrade
$ brew cask upgrade --greedy

Reinstall outdated casks

$ brew cask outdated | xargs brew cask reinstall

Troubleshooting

$ brew doctor

Installing mongodb formula

$ brew install mongodb

To start mongodb formula

$ brew services start mongodb

To stop mongodb formula

$ brew services stop mongodb

To restart restart formula

$ brew services restart mongodb

Running brew bundle to install all packages at once

$ brew bundle

Brewfile

Restore brew and cask formula list from a backup file

$ brew install $(< packages.txt )
$ brew install $(cat packages.txt)
$ cat packages.txt | xargs brew install