Setting PATH variable in Mac permanently

Published on May 30, 2011

This post I will highlight 3 ways to change to your PATH variable.


1. The quick way

Firstly, check your current PATH

echo $PATH

If the directory (eg. /my/new/path/) you want to add is not already in your current PATH, then you can easily add with the command

export PATH=$PATH:/my/new/path/

Done. Right?

It’s not really done, if you would like the PATH to change permanently (which is usually the case). This quick method only change the PATH for that bash session. If you close the terminal or open a new terminal, the PATH reverts back.


2. Set permanently for a user

This brings us to the second way of setting PATH permanently for a user.

Edit the user’s bash profile (replace USERNAME)

pico ~USERNAME/.bash_profile

Insert (or edit) this line


Press ctrl-x, then ctrl-y, to save the file.



3. Set for all users

As a bonus, if you want the PATH to change for all users

sudo pico /etc/paths

Enter your superuser password to edit, and insert or edit this link


That’s it! Enjoy your path!


beautiful biking path