Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

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
add comment

1 Answer

up vote 6 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
1  
Works perfectly. I did PATH=~/bin:$PATH though, a bit cleaner ;) –  Olivier Lalonde Feb 10 '11 at 0:58
2  
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
2  
You don't have to hardcode your username, the following works too: PATH="$HOME/bin:$PATH" –  papukaija Jun 24 '11 at 13:00
add comment

Your Answer

 
discard

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.