Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > iPhone, iPod and iPad > iOS > Jailbreaks and iOS Hacks

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 30, 2007, 08:51 PM   #1
brando88
macrumors 6502
 
Join Date: Nov 2007
adding things to your PATH

UNIX only, windows programming is a little out of my field lol.

Many command line utilities ask you to add certain things to the PATH. (eg. /var/root/bin)

So I thought I'd post a thread on how to do so... Here it is.

It's also on my site, link in the signature.

The PATH environment variable is a colon-delimited list of directories that your shell searches through when you enter a command.

Program files (executables) are kept in many different places on the Unix system. Your path tells the Unix shell where to look on the system when you request a particular program. Having more directories in your path will reduce the number of times you get "Command not found" errors, but might put you at greater risk of activating a Trojan horse.

To find out what your path is, at the Unix shell prompt, enter:

echo $PATH

Your path will look something like the following.

/usr2/username/bin:/usr/local/bin:/usr/bin:.

You will see your username in place of username. Using the above example path, if you enter the ls command, your shell will look for the appropriate executable file in the following order: first, it would look through the directory /usr2/username/bin, then /usr/local/bin, then /usr/bin, and finally the local directory, indicated by the . (a period).

To modify your path

If you are using csh or tcsh, at the shell prompt, enter:

setenv PATH $PATH\:/dir/path

If you are using sh, ksh, or bash, at the shell prompt, enter:

PATH=$PATH\:/dir/path

In all cases, replace /dir/path with the directory you want the shell to search.

Note: The earlier entries in the path take precedence over the later ones. If you want the directories you add to your path to take precedence, then in the examples above, replace $PATH\:/dir/path with /dir/path:$PATH .
If you want to make these changes permanent, then add the commands described above to the end of your .cshrc file (for csh and tcsh), .profile file (for sh and ksh), or .bash_profile file (for bash).


EDIT*

Thank you to "WildPalms" for commenting on the article, and clarifying that the former export command is not needed.

Here is the one-line command: export PATH=$PATH:/new_path_entry

*Note* this does not apply to all shells or environments but works on OS X
__________________
[ i r brando ]
-[ 8GB iPhone ]
theiphoneproject

Last edited by brando88; Dec 30, 2007 at 09:08 PM.
brando88 is offline   0 Reply With Quote
Old Dec 30, 2007, 08:58 PM   #2
WildPalms
macrumors 65816
 
WildPalms's Avatar
 
Join Date: Jan 2006
Location: Honolulu, HI
Good article

2 tips:

If the user adds to their profile, don't include the export statement, it's unnecessary.

You can set and export on one line with: export PATH=$PATH:/new_path_entry
*Note* this does not apply to all shells or environments but works on OS X
__________________
Shiny !
"Yep!..... that went well."
WildPalms is offline   0 Reply With Quote
Old Dec 30, 2007, 09:05 PM   #3
brando88
Thread Starter
macrumors 6502
 
Join Date: Nov 2007
Quote:
Originally Posted by WildPalms View Post
Good article

2 tips:

If the user adds to their profile, don't include the export statement, it's unnecessary.

You can set and export on one line with: export PATH=$PATH:/new_path_entry
*Note* this does not apply to all shells or environments but works on OS X
Thank you, I'll edit the post.
__________________
[ i r brando ]
-[ 8GB iPhone ]
theiphoneproject
brando88 is offline   0 Reply With Quote
Old Jul 15, 2010, 12:00 PM   #4
Kludge420
macrumors regular
 
Join Date: Apr 2009
Thank you for the tutorial but it's not very useful if you want your path info to be remembered and usable by all shells. The way you're doing it the path won't be saved for the next terminal window you open and you'll have to redo the whole process all over again; not fun.

If you want to permanently alter your path for all users and all shells in OS X you need to edit the /etc/paths file.

To do this open a terminal window and type: sudo pico /etc/paths

You'll be prompted for your password and then it will open the paths file in a text editor (you can do "sudo vi /etc/paths" if you hate easy to use editors). Now you can edit your paths and they will be remember the next time you open your terminal window.

Note: You will have to exit and re-enter the shell for the path to be seen.

Last edited by Kludge420; Jul 15, 2010 at 12:07 PM.
Kludge420 is offline   2 Reply With Quote

Reply
MacRumors Forums > iPhone, iPod and iPad > iOS > Jailbreaks and iOS Hacks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
adding sth to the path juhuu123 Mac Programming 9 Jun 10, 2010 09:40 AM
Does iTunes insist on copying things to your iPod / iPhone that you told it not to? spaceballl iPod 1 Oct 16, 2008 01:52 AM
adding a file to my path jamesapp Mac Programming 1 Jun 7, 2008 01:41 PM
Is iPhone Automatically adding contacts to your address book? mashinhead iPhone Tips, Help and Troubleshooting 0 Jul 4, 2007 11:03 AM


All times are GMT -5. The time now is 10:49 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC