我有个程序在我的路上。程序在使用指定的完整路径执行时运行。但是,当我只使用它的名字运行它时,就找不到它了。
基本上,我想了解下面的输出是如何实现的,以及如何修复它,这样就可以在没有指定完整路径的情况下找到我的程序:
root:/usr/local/bin# ./siege
****************************************************
siege: could not open /usr/local/bin/etc/siegerc
run 'siege.config' to generate a new .siegerc file
****************************************************
root:/usr/local/bin# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
root:/usr/local/bin# siege
bash: /usr/bin/siege: No such file or directory
root:/usr/local/bin# wtf!?!?我在Ubuntu12.04上使用bash。另外,请注意围城的警告输出与这个问题无关,因为我只对是否可以找到和调用程序感兴趣。
发布于 2013-07-14 16:09:44
注意这里的输出:
root:/usr/local/bin# siege
bash: /usr/bin/siege: No such file or directoryBash维护路径中以前找到的可执行文件的内部哈希。在这种情况下,它提供的详细信息是,曾经有一个可执行文件在/usr/bin/密封圈上执行,并重用该路径以避免再次搜索。您需要告诉bash手动重新散列围城的路径,如下所示:
hash siege您还可以清除所有散列位置:
hash -r发布于 2016-02-29 17:40:39
造成此问题的另一个原因可能是可执行文件本身的路径位于路径上,而不是可执行文件的包含目录。
所以不要把
/home/myDir/theExecutable在这条路上,只需加上这个
/home/myDirhttps://unix.stackexchange.com/questions/82991
复制相似问题