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.
Best Answer
Note the output here:
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:
You can also clear all hashed locations: