Skip to main content
4 of 4
edited tags; edited title
Gilles 'SO- stop being evil'
  • 838.6k
  • 198
  • 1.8k
  • 2.2k

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 yet 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 the directory order in $PATH variable? In addition, is it possible to change the order of the executables started, e.g. if I type in test, then /usr/bin/test is started instead of bash-builtin test?

Martin
  • 7.6k
  • 43
  • 132
  • 219