I have a two seperate files on my computer,

which execfile

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.


you can specify the full path to the command when you run it type:




to run the exact file at that path

  • kthanks, is there a way to pick one of those commands the default one? – colorfulgrayscale May 14 '10 at 4:46
  • 6
    Yes, if you want /usr/bin/execfile to be the default one, make sure /usr/bin/ is before /usr/local/bin/ in your PATH shell environment variable. – Bertrand Marron May 14 '10 at 4:48
  • @tusbar +1 for correct answer ;) – Jacob May 14 '10 at 4:54



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:

echo $PATH

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:

export PATH=/bin:$PATH

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:

source ~/.profile

For the system-wide change, type

source /etc/profile

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".

  • BTW ask this on superuser.com – Dom De Felice May 15 '10 at 9:56

Write an alias in ~/.profile:

alias execfile='/usr/local/bin/execfile'

After the next login the right version will be chosen automatically. Start the other ones with the full path.


also check for that if they both belongs to same file - like it may be link

ls -al /usr/bin
ls -al /usr/local/bin

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

  • 1
    That will show if they're symlinked (you'll see something like "/usr/bin/execfile -> /usr/local/bin/execfile" if they are). To see if they are hardlinked, use ls -li /usr/bin/execfile /usr/local/bin/execfile and compare their inode numbers. – Dennis Williamson May 15 '10 at 13:57


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.