How do I "globalize" binaries in Linux?

4

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?

Sam

Posted 2010-02-23T01:22:24.487

Reputation:

Answers

8

All directories listed in $PATH are searched for executables.

Ignacio Vazquez-Abrams

Posted 2010-02-23T01:22:24.487

Reputation: 100 516

4

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

Treviño

Posted 2010-02-23T01:22:24.487

Reputation: 308

1It'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 – 2010-02-24T05:25:42.470

1

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

Steven Schlansker

Posted 2010-02-23T01:22:24.487

Reputation: 199

0

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

user31894

Posted 2010-02-23T01:22:24.487

Reputation: 2 245