Linux – Conflicts between /usr/bin and /usr/local/bin

linuxunix

I have an application (Exuberant Ctags) installed in /usr/bin.

I have also compiled Emacs from source, which installs its own version of ctags in /usr/local/bin.

Running ctags from the command prompt runs the Emacs version from /usr/local/bin.

Is there a way to force it use the application from /usr/bin?

I can go into /usr/local/bin and delete or rename the unwanted ctags version, but I am wondering if there is another way.

Best Answer

Edit your PATH, so /usr/bin appears before /usr/local/bin. You find out your current path with echo $PATH. To change this depends on your system, usually ~/.bashrc. There are questions here and on ServerFault dealing with where to find environment variables and which to use, ~/.bashrc or ~/.bash_profile :-)

If you do have software installed in /usr/local/bin/ that "overrides" what the system put in /usr/bin, you can create an alias to specify which executable to run on a per-program basis. For example with this ctags program, put this in your ~/.bashrc.

alias ctags="/usr/bin/ctags"

(though one of the SF links was about cygwin specifically, it is applicable on other platforms as well)