28

I have a program on my path. The program runs when executed with a full path specified. But the program cannot be found when I run it with just its name.

Essentially, I want to understand how the below output is possible, and how to fix it so that my program can actually be found without a full path specified:

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!?!?

I'm on Ubuntu 12.04 using bash. Also please note the warning output from siege is not relevant for the purposes of this question, as I am only interested in whether or not the program can be found and invoked.

43

Note the output here:

root:/usr/local/bin# siege
bash: /usr/bin/siege: No such file or directory

Bash maintains an internal hash of previously found executables in your path. In this case, it has details that at one time there was an executable at /usr/bin/siege, and reuses that path to avoid having to search again. You need to tell bash to manually rehash the path for siege like so:

hash siege

You can also clear all hashed locations:

hash -r
| improve this answer | |
1

Another cause of this problem might be that the path to the executable itself is on the path, instead of the executable's containing directory.

So instead of putting

/home/myDir/theExecutable

on the path, merely add this

/home/myDir
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.