Say we want to have our $HOME/bin added to the $PATH
First check that the PATH does not already contain our $HOME/bin, by issuing in a terminal:
echo $PATH
If our $HOME/bin is contained in the $PATH we need to do nothing further,
otherwise, proceed as follows:
If you haven’t yet, create the directory bin in your home:
mkdir bin
Edit
$HOME/.bashrc
and add the following towards the end of the file:
[[ -d $HOME/bin ]] && \ [[ ! $PATH =~ $HOME/bin ]] && \ PATH=$HOME/bin:$PATH && \ export PATH
Edit
$HOME/.profile
or
$HOME/.bash_profile
and do the same.
Log out of the system and log back in and check the path in a terminal:
echo $PATH
We should now find that the $HOME/bin is included in our $PATH, whether bash is used as a login shell or just as a terminal
Also note that the
[[ ! $PATH =~ $HOME/bin ]]
condition prevents the $HOME/bin to appear more than once in our $PATH

