Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This is the output from which -a autoconf:

/usr/bin/autoconf
/usr/bin/autoconf
/home/amumu/root/bin/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

share|improve this question

2 Answers 2

up vote 6 down vote accepted

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

 PATH=/home/amumu/root/bin:${PATH}
 export PATH

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

share|improve this answer
2  
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 at 4:22
    
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 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.

share|improve this answer
    
Nice to know this trick as well. –  Amumu May 5 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 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 at 15:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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