执行命令时,linux搜索可执行文件以执行的顺序是什么。我有以下内容:
- /bin/播放
- /home/prabhat/playframework/play
以上两个文件都在路径中。
当我从我的主目录执行它时,如下所示
prabhat@localhost~/home/prabhat/$ play
/bin/play 被执行。
linux搜索要执行的文件的顺序是什么。有没有办法改变它?
The order is defined by the entry order in your PATH variable.
Note that your shell may cache this info and when you change the PATH you may need to refresh this cache. In bash
this is done by the hash
command. See here for more information.
hash command maintains a hash table, which has the used command’s path names. When you execute a command, it searches for a command in the variable $PATH. But if the command is available in the hash table, it picks up from there and executes it
you need to move /home/prabhat/playframework/ before /bin in your path. you should be able to do this in your .bashrc or .bash_profile
something along the lines of:
export PATH=/home/prabhat/playframework/play:$PATH
hope this helps