What does "is hashed" mean when using the type command?

I was reading this post and trying out all of the commands in the first answer… I don’t really have anything else better to do right now.

Anyways, I ran through them all in regards to rm. What piqued my interest is this:

root@headdesk:~# type ls
ls is /bin/ls
root@headdesk:~# hash ls
root@headdesk:~# type ls
ls is hashed (/bin/ls)
root@headdesk:~#

Running help/man hash is not very helpful, and help type isn’t really either (it does not mention hash anywhere). Since I can’t seem to find a relation in the man/info/help pages unless I am missing something, could someone please explain what hashing is doing in regards to the type command?

Asked By: cutrightjm

||

It means stored in a hash table for quicker reference next time around.

Answered By: Michael Durrant

In bash: just type help hash and you will get a help about the built-in command hash.

Determine and remember the full pathname of each command NAME.

What that means is that after finding the location of a command the first time (or when hash is invoked), its location is remembered (hashed).

Answered By: user79743
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.