About the shell cache of hash

The shell command execution in two ways:

    Internal command (built by the shell)
        Help: internal list of commands
        enable cmd: Enable internal command
        enable -n cmd: Disable internal command
        all internal command to view the enabled: enable -a


    External commands: external executable files
        which cmd: command to view the file path, the path listed in the first match of
        which -a cmd: print all matching path
        which cmd --skip-alias cmd: remove the print command path alias
        whereis: Find File or directory

    View command types: type command

Cache Hash Table

The initial system Hash table is empty, if the system restart will be cleared when the external command is executed will find the command to the PATH, and then recorded in the Hash years, when then perform it to take Hash years, it will speed up execution.

Hash common usage

hash hash displays cache

hash hash -l display buffer, comprising hash aliases

hash -p path name to the path from the alias name

hash -t name Print name of the path

Clear name cache hash -d name

hash -r clear all caches

 

Order shell command search path: Alias ​​-> internal command -> Hash storage path -> hard disk path

Guess you like

Origin www.cnblogs.com/ChairmanYSL/p/12215869.html