Sometimes you want to install software that is typically categorized as F/OSS (Free, or Open Source Software).

Homebrew is a packaging system for OS X which makes installing (and keeping them updated) many of these bits of software easy.

Install Xcode

To start with, we need to install the Xcode tools. Its not necessary to install all of Xcode to do this. We can simply run:

xcode-select --install

Install homebrew

Now that we have Xcode tools installed, we can install homebrew. Start by looking at the web page: http://brew.sh

When you’re ready, open up Terminal.app and paste in the following (this assumes you are using a bourne shell derivitive. If not, you will need to modifiy as appropriate):

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

Homebrew installs a bunch of files into ‘/usr/local’ and its intended to be run as a regular user (with the implication that ‘/usr/local’ needs to be owned and writable by said regular user.

Brew update

The first thing you should know how to do is update the brew repository.

brew update

This will reach out to github and pull down the current version of the homebrew repository, containing all the recipies for packages you may want to use.

Brew install example

Now that you have homebrew installed, you can use it to install software. For example, I like to install the ‘mtr’ package instead of using the traditional traceroute. The install process looks like this:

[louisk@iPwn louisk ]$ brew install mtr
==> Downloading ftp://ftp.bitwizard.nl/mtr/mtr-0.86.tar.gz
Already downloaded: /Library/Caches/Homebrew/mtr-0.86.tar.gz
==> ./configure --prefix=/usr/local/Cellar/mtr/0.86 --without-gtk
--without-glib
==> make install
==> Caveats
mtr requires root privileges so you will need to run `sudo mtr`.
You should be certain that you trust any software you grant root privileges.

==> Summary
🍺  /usr/local/Cellar/mtr/0.86: 8 files, 148K, built in 13 seconds
[louisk@iPwn louisk ]$

The output from running ‘sudo mtr -c 1 google.com’ might look like:

                             My traceroute  [v0.86]
iPwn (0.0.0.0)                                         Wed Jul  8 18:07:53 2015
Keys:  Help   Display mode   Restart statistics   Order of fields   quit
                                       Packets               Pings
 Host                                Loss%   Snt   Last   Avg  Best  Wrst StDev
 1. pfsense.work                      0.0%     1    1.7   1.7   1.7   1.7   0.0
 2. bc1041.bendcable.com              0.0%     1   10.9  10.9  10.9  10.9   0.0
 3. 60.157.100.208.bendbroadband.com  0.0%     1   10.2  10.2  10.2  10.2   0.0
 4. 70.157.100.208.bendbroadband.com  0.0%     1   11.0  11.0  11.0  11.0   0.0
 5. 208.100.157.0                     0.0%     1   18.9  18.9  18.9  18.9   0.0
 6. google.nwax.net                   0.0%     1   20.0  20.0  20.0  20.0   0.0
 7. 66.249.94.214                     0.0%     1   22.4  22.4  22.4  22.4   0.0
 8. 66.249.94.201                     0.0%     1  104.3 104.3 104.3 104.3   0.0
 9. 209.85.241.42                     0.0%     1   62.9  62.9  62.9  62.9   0.0
10. 216.239.50.249                    0.0%     1   77.7  77.7  77.7  77.7   0.0
11. 74.125.37.37                      0.0%     1  149.3 149.3 149.3 149.3   0.0
12. 72.14.235.14                      0.0%     1  156.6 156.6 156.6 156.6   0.0
13. 72.14.234.232                     0.0%     1  162.1 162.1 162.1 162.1   0.0
14. 66.249.94.53                      0.0%     1  160.5 160.5 160.5 160.5   0.0
15. 66.249.95.137                     0.0%     1  162.6 162.6 162.6 162.6   0.0
16. zrh04s05-in-f5.1e100.net          0.0%     1  168.7 168.7 168.7 168.7   0.0

If you don’t want to have to call mtr with sudo, you can do the following:

chmod 4755 /usr/local/Cellar/mtr/0.86/sbin/mtr
sudo chown root /usr/local/Cellar/mtr/0.86/sbin/mtr

You will probably have to substitute a newer version for the ‘0.86’. After you run these commands, you should be able to execute mtr with out using sudo.

Now, you can go use brew to install other software. Search the list of available packages with

brew search

If you don’t specify a name or an expression ‘/expression/’, it will dump all that is available.

Once you’ve selected the package you wish to install, you can

brew install <package_name>

Brew upgrade (all)

Lastly, you should know how to upgrade packages you’ve installed. Presuming you’ve already run a ‘brew update’ (discussed above), you should run

brew upgrade --all

This will look through all of the packages you have installed, compare it to the current list (this information was fetched when you ran ‘brew update’), and then it will upgrade any packages that are out of date.