How to Reset the Command Path in Bash

Occasionally when using bash after installing or updating packages, you may run into a problem like the following when trying to invoke a command:

#nano example.txt
-bash: /usr/bin/nano: No such file or

In this case, after verifying the location of nano through which or whois, and checking your $PATH, you show the path is correct and the command is installed correctly.

# which nano

# whereis nano
nano: /usr/bin/nano /usr/share/nano /usr/share/man/man1/nano.1.gz

# echo $PATH

Once you've confirmed that it should be working, the problem can be fixed in one of two ways.

1. Start a new bash session by terminating your current one.

2. Run the following command:

hash -r

The hash command is a bash built-in to reload bash.