Using CENTOS 7 and BASH, after creating a new user, the user has repeating lines in the path variable.
I've looked at this site $PATH duplication issues but it's for a .zshrc. Also, this is for the default profile just after a new user is added, so I'm not doing anything extra.
For example, if I create the user 'bob' and then view bob's path, it looks like this:
$ echo "${PATH//:/$'\n'}"
/usr/lib64/qt-3.3/bin
/sbin
/bin
/usr/bin
/usr/local/bin
/usr/local/sbin
/usr/sbin
/home/bob/.local/bin
/home/bob/bin
/home/bob/.local/bin
/home/bob/bin
/home/bob/.local/bin
/home/bob/bin
As you can see, both /home/bob/.local/bin
and /home/bob/bin
are in the path 3 times. The new (default) .bash_profile
contains the following lines for the path variable:
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
Also, anytime I add on a new path to the existing one in .bash_profile
, the new (added) path also repeats itself. For example, adding /opt/mystuff
to the path will repeat itself...
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/opt/mystuff
export PATH
Will yield...
$ echo "${PATH//:/$'\n'}"
/usr/lib64/qt-3.3/bin
/sbin
/bin
/usr/bin
/usr/local/bin
/usr/local/sbin
/usr/sbin
/home/bob/.local/bin
/home/bob/bin
/opt/mystuff
/home/bob/.local/bin
/home/bob/bin
/opt/mystuff
/home/bob/.local/bin
/home/bob/bin
/opt/mystuff
So, why are these path lines repeating themselves and is it a problem?
If it is a problem, how can I fix it?
Thanks for any & all help.
PATH=$PATH:$HOME/.local/bin:$HOME/bin
takes the current value of$PATH
, and sticks:$HOME/.local/bin:$HOME/bin
at its end. AndPATH=$PATH:$HOME/.local/bin:$HOME/bin:/opt/mystuff
takes the now-current value of$PATH
and sticks:$HOME/.local/bin:$HOME/bin:/opt/mystuff
at the end... So you get$HOME/.local/bin
and$HOME/bin
twice. Perhaps you have a similar assignment somewhere a third time?~/.bash_profile
repeatedly from e.g.~/.bashrc
?