I have a two seperate files on my computer,
which execfile /usr/local/bin/ /usr/bin/
so, i have two files with the same name in two different directories. How can I specify exactly which command to run?
migrated from stackoverflow.com May 15 '10 at 9:58
This question came from our site for professional and enthusiast programmers.
also check for that if they both belongs to same file - like it may be link
and check whether they are linked together
if they are linked then u can execute any no-difference, else you have to specify full path
you can specify the full path to the command when you run it type:
to run the exact file at that path
When trying to execute a command foo, foo is searched in the directories specified by the PATH environment variable, in the same order as they are specified. If you want to avoid this, type the full path to the executable.
Type this in a terminal:
to see your actual PATH environment variable content.
For example, if you want to always execute first executables inside /bin, make sure /bin comes first inside $PATH. You can specify PATH in the .profile file in your home directory. So for the example above, edit the file and put this line at the end:
This will work only for your user. If you want to specify $PATH in a system-wide fashion (it will work for all users except for those who change it in their .profile), add the same line above in the file /etc/profile (you will need root privileges.)
Also remember that profile files are only parsed initially. This means that if you edit your personal .profile file, you will have to make your shell re-parse it. You can do this logging out and logging in again or otherwise typing:
For the system-wide change, type
This will make your current shell session re-parse the profile file. If you want your complete bootstrapped system to parse it again, I think you better restart your session.
Also remember that this may change if you use a shell other than bash.
You can find some interesting information inside the bash man page: http://linux.die.net/man/1/bash
See section "Command Execution".
Write an alias in ~/.profile:
After the next login the right version will be chosen automatically. Start the other ones with the full path.