This question already has an answer here:

Show how you can add /home/<yourusername>/bin to the $PATH variable. Use $HOME (or ~) to represent your home directory.

share|improve this question

marked as duplicate by Panther, Thomas Ward, Radu Rădeanu, falconer, mikewhatever Jan 8 '14 at 20:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 31 down vote accepted

To do that you need to type in your terminal:

export PATH=$PATH:$HOME/bin

Where "$HOME/bin" is the directory I assume you want to add. This change is only temporary (it works only in the current session of the shell) to make it permanent add the previous line to your .bashrc file located in your home directory.

share|improve this answer
2  
I would use /home/user_name rather then $HOME – Panther Jan 8 '14 at 18:27
2  
It is the same. If you try "echo $HOME" you will probably see the folder /home/user_name... – Swordfish90 Jan 8 '14 at 19:51
    
$HOME is a variable and is thus ambiguous. IMO it is best to use the full path in scripts and when adding to your $PATH – Panther Jan 8 '14 at 19:54
1  
@bodhi.zazen Your HOME is not guaranteed to by at the same location on different systems. For example, I use the same .bashrc on Linux and MacOS, and hard-coding the full path would not work. – Gauthier Aug 16 '17 at 11:34

Ubuntu (and Debian based distros) automatically add $HOME/bin to the PATH if that directory is present. You can check this in ~/.profile:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
share|improve this answer
1  
In case ~/.profile is not loaded add this to your ~.bashrc: PATH="$HOME/bin:$PATH" – rubo77 Jul 13 '14 at 10:50
    
What does "-d" do? This actually prepends several ~/bin into $PATH if you have multiple logins. – sdaffa23fdsf Feb 11 '15 at 12:48
    
@sdaffa23fdsf "-d" is for a directory. To check its existence – Hakeem Wahab Mar 11 '15 at 8:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.