APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

© July 2005 Tony Lawrence

Front Loading Commands

This is the answer to Front Loading Commands

The bash shell maintains a table of commands you have used so that it can execute them more quickly without looking them up in $PATH. You can see the current list and the number of times you have used the command just by typing "hash".

If you type "ls", the shell remembers where it found it, and won't look in $PATH again until you reset $PATH or you explicitly type "hash -r". So, if this administrator probably did something like this:

# PATH=/specialstuff:$PATH
# ls
# cp mynewls /specialstuff/ls

The first command reset the hash table. However, he then ran "ls" - he probably forgot what he called his version and needed to see it before he could give the right copy command. The hash was reset by setting $PATH, so bash had to search each directory again to find "ls", but since there was not yet any "ls" in /specialstuff, bash found the system /bin/ls again. Bash put /bin/ls into its hash table so that it wouldn't have to search $PATH yet again. The cp put ls into /specialstuff, but nothing told bash to update its hash, so as far as it was concerned, the version in /bin was still the right one to use. The "which" command looks through $PATH, but doesn't look in the hash table (it probably should), so it confused things even more.

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> Answer to Front Loading Commands

Inexpensive and informative Apple related e-books:

Take control of Apple TV, Second Edition

Take Control of Automating Your Mac

Sierra: A Take Control Crash Course

Take Control of Pages

Take Control of Parallels Desktop 12

More Articles by © Tony Lawrence

Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Printer Friendly Version

Great minds discuss ideas; average minds discuss events; small minds discuss people. (Eleanor Roosevelt)

Linux posts

Troubleshooting posts

This post tagged:


Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode