How do I clear Bash's cache of paths to executables?

When I execute a program without defining the complete course to the executable, and also Bash has to look the directory sites in $PATH to locate the binary, it appears that Bash bears in mind the course in some type of cache. As an example, I mounted a construct of Subversion from resource to /usr/local, after that keyed in svnsync help at the Bash punctual. Bash situated the binary /usr/local/bin/svnsync for "svnsync" and also implemented it. After that when I removed the installment of Subversion in /usr/local and also re - ran svnsync help, Bash reacts:

bash: /usr/local/bin/svnsync: No such file or directory

But, when I start a new instance of Bash, it locates and also implements /usr/bin/svnsync.

Just how do I clear the cache of courses to executables?

343
2019-05-13 03:35:30
Source Share
Answers: 2

To clear simply one access you require a various flag :

hash -d svnsync

The -r flag does not take a parameter and also will certainly constantly delete the whole cache.
(At the very least in bash 3.2.39 on Debian Lenny)

29
2019-12-02 00:01:55
Source

bash does cache the complete course to a command. You can validate that the command you are attempting to execute is hashed with the type command:

$ type svnsync
svnsync is hashed (/usr/local/bin/svnsync)

To clear the whole cache:

$ hash -r

Or simply one access:

$ hash -d svnsync

For added details, get in touch with help hash and also man bash.

427
2019-05-17 14:11:45
Source