How to change which program is executed by default

executablepath

Surely this is an easy question, that I just don't know how to search for, but if I have two identically named executable files, one in /usr and one in /usr/local (for example), how can I change which one is executed by default without specifying the path, as in /usr/local/file, if $ which returns /usr?

Centos6.4 btw.

Best Answer

It's not always as simple as "which comes first in $PATH;" see https://superuser.com/questions/358695/how-does-linux-decide-which-executable-im-trying-to-run. For a quick fix, set an alias in .bashrc (assuming you're using bash...)

alias gorgonzola='usr/local/gorgonzola'

Note: white space is not allowed around the "=" sign.

Related Question