6

Where is the correct place to store user-local executable files?

echo $PATH gives

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

It doesn't include eg. $HOME/bin

Would $HOME/bin be advisable? Or $HOME/opt/bin ....

I guess I would have to add that to my .profile too?

muru
  • 197,895
  • 55
  • 485
  • 740
JohnDoe
  • 173
  • Do not change anything, just mkdir ~/bin, log out and log back in and it'll be there. – Sergey Sep 20 '12 at 21:07
  • 1
    Be sure to make all directories in you PATH non-writable, as writable bin directories are a major security hole. – Vladislav Ivanishin Sep 20 '16 at 16:11
  • If this is just for the user, then binaries can be placed in ~/.local/bin. My PATH didn't include this location when it was empty. But I added a binary to it, rebooted, and it was automatically added to $PATH. If it's for all users of the machine, then /usr/local/bin. – Daniel Apr 24 '22 at 20:49

2 Answers2

8

I think if you add a $HOME/bin directory it should be added to the path automatically, looking in my .profile would indicate this

Yes just checked and by creating a $HOME/bin directory the next time you log in its automatically added to the path.

Hope that helps

apacheuk
  • 928
  • 3
    BTW if you jut created this folder you will need to source .profile file in order to make new adde binary to be availible using $PATH : # source ~/.profile – micrub Feb 12 '14 at 15:07
6

Based-on what you are describing, I'm thinking that you should install your executables to /usr/local/bin/.

Here is an answer to a similar question that backs-up this assessment: What is the best place to install user apps?

Otherwise, you certainly could create a ~/bin directory and add it to your path. IMO that is a viable solution if those apps will/should be used only by your user. But you will run into some security headaches if another user has a need for those apps later on.

Aaron
  • 6,714
  • 2
    I share my laptop, on which I am hacking, with my wife. she will probably never need on of my executables. Thank's for your security concerns though! – JohnDoe Sep 21 '12 at 05:44