Go Back   The macosxhints Forums > OS X Help Requests > UNIX - Newcomers



Reply
 
Thread Tools Rate Thread Display Modes
Old 04-11-2012, 09:10 PM   #1
yehudithasin
Prospect
 
Join Date: Apr 2012
Posts: 3
changing $PATH and finding .profile?

Hi all,
I am pretty new to unix - so sorry if this is trivial....On Mac OS X 10.6 running terminal:
I need to add a directory to my $PATH, tried

PATH=$PATH\:/usr/local/newdir; export PATH

For whatever reason when I do this now it works only for this particular shell, and the PATH gets reverted to what it was before.
After some reading on the web I understood that I may need to change it in .bash_profile or .profile files, but I can't find them anywhere (looking through hidden files with ls -a)....
How do I permanently change $PATH and where is it stored?

Thank you in advance
Yu
yehudithasin is offline   Reply With Quote
Old 04-12-2012, 12:22 PM   #2
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,459
See this Unix FAQ
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 04-12-2012, 12:53 PM   #3
yehudithasin
Prospect
 
Join Date: Apr 2012
Posts: 3
Hi Hayne

I looked at it before posting, the export works for the specific shell, for whatever reason the PATH keeps reverting for every new shell I open. The shell is bash...

Yu
yehudithasin is offline   Reply With Quote
Old 04-12-2012, 05:03 PM   #4
trevor
Moderator
 
Join Date: Jun 2003
Location: Boulder, CO USA
Posts: 19,841
Look at this specific section of the Unix FAQ: How do I set up my shell execution PATH?, specifically the words 8 through 12 under both the sections that are titled, "Setting PATH in the xxxx Shell".

Trevor
trevor is offline   Reply With Quote
Old 04-12-2012, 05:13 PM   #5
yehudithasin
Prospect
 
Join Date: Apr 2012
Posts: 3
Hi Trevor - thanks for the response, apparently I am missing something:
this is what that sections says:
"Setting PATH in the bash shell
To set up your PATH in bash, you edit the file ~/.profile (using any text editor that can save in plain text - e.g. 'pico') and add a line like the following...."
I dont have a .profile or .bash_profile file anywhere...not in ~ directory and not in any system directory I tried to look in. I looked through the hidden files as well.

It also says to use export:
"export PATH="/bin:/sbin:/usr/bin:/usr/sbin"
The above would set the following folders/directories to be in your PATH...."


This seems to work only for the specific shell instance I am running. If I open a new shell, in that shell the PATH variable reverts to what it was before.....
I think I dont have Fink installed so the next paragraph is not relevant. After that it goes to tcsh shell.

Did I miss anything in that section?
Yu
yehudithasin is offline   Reply With Quote
Old 04-12-2012, 05:20 PM   #6
trevor
Moderator
 
Join Date: Jun 2003
Location: Boulder, CO USA
Posts: 19,841
Quote:
Originally Posted by yehudithasin
I dont have a .profile or .bash_profile file anywhere...not in ~ directory and not in any system directory I tried to look in. I looked through the hidden files as well.

If you don't have a ~/.profile file, then you'll need to create one.

Setting the PATH with a command, but not actually saving it to a configuration file such as ~/.profile, will just change the PATH for the shell that you currently have running, not into the future.

Trevor
trevor is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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



All times are GMT -5. The time now is 02:42 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.