What should I do if I want to be able to run a given program regardless of my current directory? Should I create a symbolic link to the program in the /bin
folder?
|
||||
If you just type If you want to change it permanently add |
||||
|
The short answer is that to run the program, no matter what your directory, you need to have the program's directory in your search path. The problem can be solved by putting the program into a folder thats already in that path, or by adding a new folder to the path - either will work. The best answer depends on: Is this program a downloaded program that you have compiled yourself from source? Its quite likely will have an install mechanism already. In the folder that you compiled the program, as root, run 'make install' Is this program a downloaded program that you want to make available as part of the standard programs on the computer? Makes sense to put this kind of application into a standard folder. its quite common to use directories such as /usr/local/bin for such programs. You will need root access to do this. This is a program that you have written for yourself and/or you have no special privilages on the computer. Creating a folder in your home directory called 'bin', and placing the program in there. You may need to edit your login script to add the full path to this folder (e.g. /usr/home/jeremy/bin) Whilst you could just add its current directory to the search path, you will have to keep doing this with every new program - and is more work in the longer term. |
|||
|
Placing a link to the file in the
You can actually place (install) the executable file in Unless I'm setting up a program that I expect other users to use, that's not what I usually do: I create a bin directory just for me in my home directory, and I edit my shell profile to add |
||||
|
If you want to run a command
Note that 2. is a security risk on multi-user systems: imagine you |
|||||
|
Messing with the My "locally installed" programs are in |
|||
|
protected by Community♦ Oct 14 '15 at 21:22
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
~/bin/
folder, add THAT to your path, and create symlinks in that folder to anything you wanted to be executable from anywhere. – frabjous Nov 6 '10 at 20:16