user2330497
user2330497

Reputation: 419

How can I change the binary file link to something else

I have two questions and they are linked. I execute the command like this:

python on the shell and it opens the shell.

Now I want

  1. To which file it is linked. I mean when I run python then what is the path of file it opens like /usr/bin/python or what?

  2. The other questions is I want to change that link to some other location so that when I run python then it opens /usr/bal/bla/python2.7.

Upvotes: 3

Views: 5939

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 753585

The command run when you type python is determined primarily by the setting of your $PATH. The first executable file called python that is found in a directory listed on your $PATH will be the one executed. There is no 'link' per se. The which command will tell you what the shell executes when you type python.

If you want python to open a different program, there are a number of ways to do it. If you have $HOME/bin on your $PATH ahead of /usr/bin, then you can create a symlink:

ln -s /usr/bal/bla/python2.7 $HOME/bin/python

This will now be executed instead of /usr/bin/python. Alternatively, you can create an alias:

alias python=/usr/bal/bla/python2.7

Alternatively again, if /usr/bal/bla contains other useful programs, you could add /usr/bal/bla to your $PATH ahead of /usr/bin.

There are other mechanisms too, but one of these is likely to be the one you use. I'd most probably use the symlink in $HOME/bin.

Upvotes: 3

Related Questions