Skip to main content
1 of 4
Martin
  • 7.6k
  • 43
  • 132
  • 219

change the order of executables started in bash

If I execute the test command in bash, test(evaluates conditional expression) built-in utility is started:

$ type test
test is a shell builtin
$ type -a test
test is a shell builtin
test is /usr/local/bin/test
test is /usr/bin/test
$ 

However, as seen in output of type -a test above, there is another test in /usr/local/bin directory and jet another one in /usr/bin directory. How are executables ordered, i.e. are the built-in commands always preferred and then the rest of the commands depend on directory order in $PATH variable? In addition, is it possible to change the order of executables started, e.g. if I type in test, then /usr/bin/test is started instaed of bash-builtin test?

Martin
  • 7.6k
  • 43
  • 132
  • 219