Question

When i run env it shows 3 times /usr/bin under PATH . Same for every path under PATH title.
For example - my scala bin directory shows 3 times .

However, in my .bash_profile, it is written just one time . Also its not in .bashrc also. I need to make this 3 occurrences to 1, as even though I remove some path under PATH in .bash_profile, it still shows 2 times , which means that path is still set.

echo $PATH shows the same thing.
And , if it matters I am using macosx.

Was it helpful?

Solution 2

OK..So I found the solution.
Here is what I was doing :-
1) vi ~/.bash_profile
2) make changes
3) source ~/.bash_profile to see those changes in effect .

It seems for every editing and subsequent source command, temporarily keeps in current session.
So , if i made changes 3 times and consequent source command, it shows 3 times the same path if i do echo $PATH or env. Closing the terminal and restarting it puts back everything to normal.

So, it was just a matter or restarting the terminal!!

Clarification :- Different platforms may perform differently. I found macosx-10.7 works this way.

OTHER TIPS

There are many files that can setup PATH, usually adding to a previously defined $PATH (so as not to miss any important directory).

See for example the guide at http://linuxfromscratch.org/blfs/view/svn/postlfs/profile.html

You would like to see, amongst possibly others : /etc/profiles /etc/bashrc ~/.bash_profile ~/.bashrc

And be careful : don't edit the wrong files or put "login-only things" into a "for non-login shell" file, and vice versa.

Citing the /etc/profile example from the link above, by James Robertson , you can see each file's meaning:

  • /etc/profile : System wide environment variables and startup programs.
  • /etc/bashrc : System wide aliases and functions should go in /etc/bashrc.
  • ~/.bash_profile : Personal environment variables and startup programs should go into ~/.bash_profile.
  • ~/.bashrc : Personal aliases and functions should go into ~/.bashrc.

(warning: changing /etc/profile has to be made CAREFULLY. It's used in many low level stages of bootup, and is inherited by almost everything running in your OS, so be careful that a small "unhamrful" change may wreak heavoc in your system)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top