Configuring the PATH System Variable

Pages
Contributors: santaimpersonator
Favorited Favorite 1

Mac OSX and Linux Based Systems

On Mac OSX and linux based systems, users can display the paths for the $PATH system variable by entering echo $PATH into the terminal.

Note: The commands below use the GNU nano text editor. Feel free to use another text editor of your choice (such as vi for Vim).

To modify the variable:

  1. Open up Terminal and run the following command to edit the paths file: sudo nano <file path location>
    • There are several locations where users might be able to modify the $PATH system variable:
      • /etc/paths (Mac OSX - Mountain Lion)
      • /usr/bin
      • /usr/local/bin
      • /usr/local/sbin
      • /usr/sbin
      • ~/.bash_profile
      • ~/.bashrc
      • ~/.profile
  2. Enter the super user (administrative) password, if prompted.
  3. Enter the modifications for the path you wish to add.
    • The entry field is usually near the bottom of the file.
  4. Hit Ctrl+X to quit.
  5. At the input prompt, send Y and hit Enter or Return to save the modified buffer.

PATH variable
Displaying paths of $PATH variable and accessing the ~/.profile file for modifications. (Click to enlarge)

That’s it! To verify the changes, in a terminal window, type: echo $PATH

Note: Another common method is to use the export command in the terminal.

Example: export PATH=$PATH:<file path to be added>