Homebrew is the most popular package manager for macOS. As the official documentation says, using the manager is the easiest and most flexible way to install the UNIX utilities that Apple didn’t include with macOS.
Assuming Homebrew is installed following commands install, remove and upgrade packages:
Remove old versions of installed packages
Try to install already installed package
List installed packages
Check what updates are available:
To speed up the process of upgrading and cleaning up packages set up the alias:
To preserve the alias add it to the ~/.profile or ~/.bash_profile file.