Linux 路径与命令搜寻顺序

  1. 以相对/绝对路径运行命令,例如『 /bin/ls 』或『 ./ls 』;
  2. 由 alias 找到该命令来运行;
  3. 由 bash 内建的 (builtin) 命令来运行;
  4. 透过 $PATH 这个变量的顺序搜寻到的第一个命令来运行。

透过 type -a ls 可以查询到命令搜寻的顺序

原文地址:https://www.cnblogs.com/niaomingjian/p/8304013.html