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 these 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 Mac OSX.

2 Answers 2


Duplicate paths won't hurt anything.

There likely is a script somewhere that is overwriting the path variable. Try the following to narrow down where the variable is being set.

See if there is an environment variable overwriting the path
logout + log back in

echo $PATH

See if a fresh shell has the same path set

sudo su foo -  
echo $PATH

See if sudo with an initial login has the path set

sudo su foo -i   
echo $PATH

Sounds like you have already checked your ~/.bashrc and ~/.bash_profile Check if there are any scripts in /etc/profile


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.

  • 1
    Well, not exactly. Your .bashrc will contain a line like "PATH=$PATH:/~/.local/bin" - an extension of the somewhere else already predefined path, and there it will add the same things again and again, if performed multiple times. May 25, 2022 at 11:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .