Mac Terminal tip: Adding a directory to the $PATH environment variable

The Mac has a unique way of setting up its $PATH variable. These are the locations the BSD portion of OS X looks at to find programs to run. In this case the list of paths can be found in the file /etc/paths. To edit it the administrator needs to sudo their favourite editor since the file itself is owned by root. For example “sudo pico /etc/paths”.

This is useful for the programmer who wants to have their programs accessible anywhere in the terminal. In my case I added “~/bin” to the end of the file. This allows any user to create a program or script in their own “bin” directory.

As someone who has done this in Linux I can say it is a whole lot easier to do this in OS X.

About the Author