How do I "globalize" binaries in Linux?
Solution 1:
All directories listed in $PATH
are searched for executables.
Solution 2:
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
Solution 3:
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