This is the output from which -a autoconf:


I want to use autoconf in my home directory since it's newer version compare to the default in the server. How to set it as the default? I don't want to overwrite /usr/bin/autoconf or write to /usr/local/bin


You could change the PATH such that autoconf in your home directory would be picked:

 export PATH

This would cause autoconf to be picked from /home/amumu/root/bin, if it's available in the location.

  • 3
    This is the approach that I would take, but you have to take care of any other executables in that directory also take precedence over ones with the same name, not just autoconf – Anthon May 5 '14 at 4:22
  • 1
    That problem is solvable by a /home/amumu/.path directory which contains symbolic links for all programs where you have an explicit preference, but nothing else. Put that first in $PATH, and it will only affect the names for which you have explicitly created shortcuts. – MSalters May 5 '14 at 14:57

You can define a function named autoconf in .bashrc file:

autoconf() {
  /home/amumu/root/bin/autoconf "$@"

You should logout and login again, or start a new terminal to see the change:

$ type autoconf
autoconf is a function
autoconf () 
    /home/amumu/root/bin/autoconf "$@"
autoconf is /usr/bin/autoconf

In this case, when you type autoconf in terminal, your own version in .bashrc is used instead of system /usr/bin/autoconf.

  • Nice to know this trick as well. – Amumu May 5 '14 at 4:56
  • You shouldn't really need to use a function, should you? Shouldn't an alias work just as well? – HalosGhost May 5 '14 at 15:16
  • Yes. It's only my hobby. I often use alias for make some default options for command. Use a function is enough to override autoconf in /usr/bin, and not to worry about overriding anything else like @Anthon comment above. – cuonglm May 5 '14 at 15:22

Consider using an alias:

alias autoconf="/home/amumu/root/bin/autoconf"

(where I'm using the bash syntax for alias). Add this line to your ~/.bashrc or equivalent to automatically define this alias for every shell session.

This has the benefit of not adding other executables to PATH that just happen to be in the same directory. Some drawbacks are that the alias won't work by default in shell scripts, and that it's a little less transparent what's going on to the end user (the alias won't show up in which, for example).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.