Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Where should I put my script in my home directory so that I can access it from any directory?

I've tried:

o@s:~/$ echo $PATH

But it seems there is no /home/user/ path. The thing is that I'd like only my user to have access to it so putting it in another directory than my home folder is not an option. Should I add something like /home/user/scripts/ to my PATH variable? If so, what's the recommended way to do it... Should I put it in my ~/.bashrc?

share|improve this question
up vote 7 down vote accepted

I add PATH=/home/djeikyb/bin:$PATH to my .bashrc, and keep all my scripts in ~/bin.

I think $PATH has greater-smaller::left-right precedence, so I put my personal bin folder first. I use a folder called "bin" because all the other program files are in folders called bin. And I even have a couple actual binaries in mine ;p

Don't forget to reload your bashrc to make changes take effect: $. ~/.bashrc

share|improve this answer
Works perfectly. I did PATH=~/bin:$PATH though, a bit cleaner ;) – Olivier Lalonde Feb 10 '11 at 0:58
The default ~/.profile already adds ~/bin to PATH, though only if ~/bin exists when you log in. And yes, it is read left to right when looking for a command. The first command by the name it is looking for, that it finds, gets executed. – geirha Feb 10 '11 at 8:04
You don't have to hardcode your username, the following works too: PATH="$HOME/bin:$PATH" – papukaija Jun 24 '11 at 13:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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