Deleted binary causes No such file or directory error in bash

Written by James McDonald

June 20, 2008

The scenario:

Your path environment is similar to “/home/user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games”

You have a binary in your path such as /home/user/bin/putty which you delete hoping to use the same binary further down the path such as /usr/local/bin/putty.

If you then try to run the binary putty you get:

bash: /home/user/bin/putty: No such file or directory

The only answer I have found at the moment is to launch a new terminal and bash seems to have forgotten about the old binary…

I’m open to other answers though… Update: Thanks to Chris for leaving a comment with the answer which is:

hash -r

Running man bash and searching for hash comes up with:

“A full search of the directories in PATH is performed only if the command is not found in the hash table…. The -r option causes the shell to forget all remembered locations.

All I knew was there was a command but I couldn’t get Google to spit it back at me. So hash -r will fix the issue.

1 Comment

Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

PDF Poster

PDF Poster

Start with a wide long image. This is just a screen shot of my desktop. widescreen.png Convert it to postscript using...

Scribus to PDF Print

Just using Scribus to design and print some lapel cards Regarding Scribus - It seems that the stable version will not...