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.

Please follow and like us:

About the Author


Mike Pfaiffer was President of A.P.P.L.E. and also the president of Digital Civilization magazine, a monthly UNIX magaine. Mike wrote a number of articles for A.P.P.L.E. and sadly passed away 19 July 2013 at age 54.