A package manager is an application that handles downloading, installing, and upgrading a set of software tools. In this case, our package manager will be responsible for downloading and installing the different Terminal commands that we want to use. If you’re a Linux user, you’ll recognize this functionally from apt-get or yum. While there are a number of different package managers available for macOS, we’ll use Homebrew for this guide. It’s well regarded, widely used, and easy to get started with. Plus, it’s free.
Installing Homebrew
Note that before you install Homebrew, you’ll need to have the Xcode command line tools installed. This comes with Xcode which is installed from the App Store.
- Open Terminal (/Application/Utilities/Terminal.app).
- Copy and paste the following command into Terminal and press Enter.
This command will run a Ruby script that downloads the Homebrew package manager from GitHub. 3. When prompted, press Enter to continue the installation.
Enter your administrator password when prompted.
When the application is finished installing, you’ll be returned to the command prompt. From here, you can view Homebrew’s documentation by typing the brew help command, or you can proceed to the next step.
Searching for Packages
To find programs and commands to download, you’ll first need to search Homebrew’s database for the program you want. For this example, we’ll search for wget. Wget is a popular Linux command that downloads files from HTTP and FTP servers.
Type the following command and press Enter:
After a moment, two results will appear named wget and wgetpaste. I don’t know what wgetpaste is, but I can find more info using the brew info command:
We can see from the description that wgetpaste will “Automate pasting to a number of pastebin services.” Since wget is an application that downloads files from the Web, that doesn’t sound like what I’m looking for. It also includes wget as a dependency, so I wouldn’t be able to run it without wget anyway.
Installing Packages
Now that I’ve confirmed that the wget package is the one I want, I’ll type in the following command and press Enter:
Homebrew will now start to work its package-managing magic. In addition to wget, I can see that it also installed openssl, which is considered a dependency for wget.
When the installation is complete, I’ll be returned to the command prompt.
Using new commands
Now that we’ve installed the wget command, we’ll be able to use it just like any other Terminal command.
For example, if we type man wget, we’ll see the man page for wget, just as expected.
And we can use wget just as we would on Linux. For example, to download a zip file from a website, we’d use a command like the one below:
Here’s a real life example of a texture pack I downloaded from TextureMate.
And when the download is completed, I’m returned to the command prompt.
Conclusion
As you become more experienced with macOS’s terminal, you may begin to realize that some Terminal commands that are common in Linux are missing from macOS. It’s easy to add new Terminal commands to your command library using Homebrew.