When I run $PATH on my terminal in Ubuntu 18.04.3, it displays the following:
/home/ubuntu/bin:/home/ubuntu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
The first part of $PATH (/home/ubuntu/bin
) shows up twice. Why?
I have tried:
grep PATH= ~/.{bash_profile,profile,bashrc}
and got:
grep: /home/ubuntu/.bash_profile: No such file or directory
/home/ubuntu/.profile: PATH="$HOME/bin:$PATH"
/home/ubuntu/.profile: PATH="$HOME/.local/bin:$PATH"
/home/ubuntu/.bashrc:export PATH="$HOME/bin:$PATH"
Removing the
export PATH="$HOME/bin:$PATH"
directive from the/home/ubuntu/.bashrc
file fixed the problem, since thePATH="$HOME/bin:$PATH"
is already covered byPATH="$HOME/bin:$PATH"
in the/home/ubuntu/.profile
file.I use Stephen Collyer's
bash_path_funcs
, described in Linux Journal way back in 2000, but the links no longer work.This link works today (2020-Mar-03):
http://web.archive.org/web/20061213023831/http://www.netspinner.co.uk/Resources.html
The
addpath
function adds an entry to a path only if it is not there in the first place.delpath -n
deletes all non-existent directories from a path, anduniqpath
deletes duplicate entries.. ~ ~