← 返回命令列表

Linux command

hash 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Show command hash table

hash

Clear hash table

hash -r

Add command to hash

hash -p [/usr/local/bin/mycommand] [mycommand]

Remove command from hash

hash -d [command]

Show path for command

hash -t [command]

说明

hash is a shell built-in that manages the hash table of recently executed commands. The shell uses this table to remember the full paths of commands, avoiding repeated PATH searches. When a command is executed, the shell stores its path in the hash table. Subsequent invocations use the cached path, improving performance. ```bash

参数

-r
Clear hash table.
-p _path_ _name_
Add path for name.
-d _name_
Delete name from hash.
-t _name_
Print path for name.
-l
List in reusable format.

FAQ

What is the hash command used for?

hash is a shell built-in that manages the hash table of recently executed commands. The shell uses this table to remember the full paths of commands, avoiding repeated PATH searches. When a command is executed, the shell stores its path in the hash table. Subsequent invocations use the cached path, improving performance. ```bash

How do I run a basic hash example?

Run `hash` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -r do in hash?

Clear hash table.