When one types a command into bash without specifying the absolute path, Bash will perform a quick lookup to find out where this command lives. Bash will first check its internal cache, which is held in a hash under the current session. If it fails to find the command here, it will check against the $PATH variable for the location of the command.

Today I had a user who installed a custom version of htop which decided to remove the older version but install the new version to /usr/local/bin/. Unfortunately, when he ran the htop command he received the following error:

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

We could simply verify the issue using the type command:

$ type htop htop is hashed (/usr/bin/htop)

to remove this entry, we can just run the following:

$ hash -d htop

or to remove all hash entries:

$ hash -r

Additionally, since the hash table is kept per session, the user could have simply logged out and then back in again.