Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After I move an executable file which I've recently executed (or more commonly, after I uninstall something from somewhere and install a different version somewhere else), bash can't find it, even if it's still on the PATH.


sudo mv /usr/bin/find /usr/local/bin

Results in:

bash: /usr/bin/find: No such file or directory

This is really annoying because it's happened to me dozens of times. How can I stop this happening?

share|improve this question
Which file, where was it, where is it now, what permissions does it have, what command did you use to move it, what is your current $PATH. Please provide significantly more detail. – EightBitTony May 27 '12 at 11:35

To clear the immediate problem:

hash -r

To stop it happening again:

set +h

to disable hashing (i.e. in-memory caching).

This can be put in a bash startup file such as /etc/bashrc.

The downside of this solution is that it slows things down a little if you have slow network filesystem(s) mounted and on the PATH.

Really, in my opinion, this is an ancient bash bug which should have been fixed years ago, and this is just a workaround.

share|improve this answer

This can happen if the new copy isn't executable, so have a look at its permissions and ensure they're correct.

share|improve this answer
up vote 1 down vote accepted

To fix the problem permanently without disabling hashing entirely, put this in your bashrc:

shopt -s checkhash

See my other answer for how to solve the immediate problem.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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