4

I noticed that my path environment variable had the path for my home's binaries $HOME/bin.

I did not add $HOME/bin directory to my path environment variable so how did $HOME/bin get added to the path?


RE - 'possible duplicate':

This question is specific to the environment variable "PATH" and is further specific to how does a specific value, i.e. $HOME/bin, get appended to the environment variable.

The "possible duplicate":

  • does NOT mention the environment variable PATH anywhere in the question or answer
  • does NOT mention anything about $HOME/bin anywhere in the question or answer
  • The possible duplicate doesn't need to mention anything about PATH since it covers environment variables in general. – muru Jul 13 '15 at 18:04

2 Answers2

6

on CentOS/RHEL 6.x (and up) and Fedora 20 (and up):

When you login, the script $HOME/.bash_profile is executed and this script adds $HOME/bin to your path.

on Ubuntu:

When you login, the script $HOME/.profile is executed and this script adds $HOME/bin to your path. (source: https://askubuntu.com/questions/49784/how-is-bin-added-to-my-path)

  • 3
    On Ubuntu $HOME/bin only gets added to the path when it exists so anyone adding it needs to make sure that .profile gets run again. – Paul Jul 13 '15 at 15:46
5

This is in /etc/skel/.profile and consequently in all users ~/.profile until changed.

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

True of Debian 6, therefore Ubuntu, and maybe others.