6 hash -r is a much more intuitive way to clear hash table than export PATH=$PATH.
source | link

To get rid of stale mappings, you can also do hash -r (or export PATH=$PATH) which effectively just purges bash's entire hash table.

To get rid of stale mappings, you can also do export PATH=$PATH which effectively just purges bash's entire hash table.

To get rid of stale mappings, you can also do hash -r (or export PATH=$PATH) which effectively just purges bash's entire hash table.

5 added 1 character in body
source | link

You'd mostly just want to do this if you wanted something out of the hash table and weren't 100% that if you could logout/back and then back in successfully, or you wanted to preserve some modifications you've made to your shell.

There are lots of little situations like that. I don't know if I'd call it one of the "most useful" commands but it does have some real use cases.

You'd mostly just want to do this if you wanted something out of the hash table and weren't 100% that if you could logout/back in successfully, or you wanted to preserve some modifications you've made to your shell.

There are lots of little situations like that. I don't know if I'd call it one of the "most useful" commands but it does have some real use cases.

You'd mostly just want to do this if you wanted something out of the hash table and weren't 100% that you could logout and then back in successfully, or you wanted to preserve some modifications you've made to your shell.

There are lots of little situations like that. I don't know if I'd call it one of the "most useful" commands but it does have some use cases.

4 clarity
source | link

Which might be useful if you just have a single executable in a directory outside of $PATH that you want to run by just type the name of instead of including everything in that directory (which would be the effect if you added it to $PATH).

The cp command caused a new version of the ls executable to show up earlier in my $PATH but didn't trigger a purge of the hash table. I used hash -d to selectively purge the entry for ls from the hash table. After I typed it again, itBash was then forced bash to look through $PATH again and when it did, it found it in the newer location (earlier in $PATH than it was running before).

You'd mostly just want to do this if you wanted something out of the hash table andweren'tand weren't 100% that if you could logout/back in successfully, or you wanted to preserve some one-time command mappings instead of havingmodifications you've made to type that out againyour shell.

Which might be useful if you just have a single executable in a directory outside of $PATH that you want to just type the name of instead of including everything in that directory (which would be the effect if you added it to $PATH).

The cp command caused a new version of the ls executable to show up in my $PATH but didn't trigger a purge of the hash table. I used hash -d to selectively purge the entry for ls from the hash table. After I typed it again, it forced bash to look through $PATH again and when it did, it found it in the newer location (earlier in $PATH than it was running before).

You'd mostly just want to do this if you wanted something out of the hash table andweren't 100% that if you could logout/back in successfully, or you wanted to preserve some one-time command mappings instead of having to type that out again.

Which might be useful if you just have a single executable in a directory outside of $PATH that you want to run by just type the name instead of including everything in that directory (which would be the effect if you added it to $PATH).

The cp command caused a new version of the ls executable to show up earlier in my $PATH but didn't trigger a purge of the hash table. I used hash -d to selectively purge the entry for ls from the hash table. Bash was then forced to look through $PATH again and when it did, it found it in the newer location (earlier in $PATH than it was running before).

You'd mostly just want to do this if you wanted something out of the hash table and weren't 100% that if you could logout/back in successfully, or you wanted to preserve some modifications you've made to your shell.

3 clean up
source | link
2 edited body
source | link
1
source | link