Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

For example, any binary placed in /usr/local/bin will run in any location. If I were to place binaries inside /myname/local/bin how would I be able to accomplish the same thing?

share|improve this question

migrated from stackoverflow.com Feb 24 '10 at 4:07

This question came from our site for professional and enthusiast programmers.

add comment

4 Answers

All directories listed in $PATH are searched for executables.

share|improve this answer
add comment

To enable your custom path by default you can add:

export PATH="/myname/local/bin:$PATH"

at the bottom of your ~/.bashrc (for user only) or /etc/profile (for all system users) or any new file like /etc/profile.d/mypath.sh

share|improve this answer
    
It's a good idea to put your custom path after the default one unless you want to override default behavior. export PATH="$PATH:/myname/local/bin" –  Chris Nava Feb 24 '10 at 5:25
add comment

The search path for binaries is stored in an environment variable, PATH

You can inspect the current value:

[steven@scstop:~]% echo $PATH

/opt/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Note how it's a colon separated list of directories. When you type "mybinary" at the prompt, your shell will go through these directories (in order) and execute the first one it finds.

To add /myname/local/bin to the PATH, do this (in a bash-like shell)

export PATH=$PATH:/myname/local/bin

share|improve this answer
add comment

Modify your $PATH environment variable in your profile to include /myname/local/bin. eg export PATH="/myname/local/bin:$PATH"

share|improve this answer
add comment

Your Answer

 
discard

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