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?


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

  • 1
    Works perfectly. I did PATH=~/bin:$PATH though, a bit cleaner ;) – Olivier Lalonde Feb 10 '11 at 0:58
  • 3
    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
  • 3
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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