Adding/removing items from PATH on Mac
Posted: 22/02/12
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:
/users/yourname/myfolder
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
Popular categories:
Recent posts:
- Mac OS find files using regex
- ADB device driver won't install
- Eclipse: An error has occurred. See the log file .metadata/.log
- Updated blinkbox iPad app
- Nexus 7 doesn't appear in adb devices list
- Improve the keyboard in the Samsung ICS update
- 403 Forbidden error on Mac web server
- Getting error with manually created NIB?
- Presenting at Flash Oxford
- Failed to get the task for process xx
- more...
Publications:
Places you'll find me:
Archive:
- August 2024
- July 2024
- June 2024
- May 2024
- April 2024
- March 2024
- February 2024
- January 2024
- December 2023
- November 2023
- October 2023
- September 2023