Adding/removing items from PATH on Mac

Posted: 22/02/12

An image of Adding/removing items from PATH on Mac

In Flash Mobile Application Development for Dummies, I said that adding a new path variable on your Mac was a little beyond the scope of the book. That said, I wanted to put the knowledge somewhere so that those looking for further reading on the subject are able to accomplish this task.

Let's assume you have some executables in the directory /users/yourname/myfolder/ and want them to be available at the Terminal prompt, without having to type the full path to them each time. Here's how to make them available on your PATH variable:

1. Open Terminal (Applications->Utilities->Terminal).

2. Paste the following into the Terminal window.

sudo pico /etc/paths

3. Press the Return key.

4. Enter your logon password and press the Return key.

The Terminal window presents the contents of the paths file, with each path entry listed on a new line.

5. Put the cursor on the empty line below the last entry and type the new directory path that you want to add. For example:


6. Press Ctrl+O (to save).

7. At the File Name to Write prompt, just press the Return key.

The message "[Wrote x lines]" displays.

8. Press Ctrl+X (to exit the editor).

Terminal then returns to the prompt screen and the update is complete. To verify that the new path has been correctly saved:

1. Press Cmd+Q (to quit Terminal).

2. Reopen Terminal.

3. Paste, or type, the following into the Terminal window:

echo $PATH

4. Press Return.

The list of paths that are stored in the paths file are listed. If you did everything right, path should be in the list.

Keywords for this post: path, mac, environment, variable, sudo, osx, lion, snow leopard, mountain lion, terminal