hash
shell built-in that manages the hash table of recently executed commands
TLDR
SYNOPSIS
hash [options] [name...]
DESCRIPTION
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.
hash
# Clear after installing new software
hash -r
# Check where a command is hashed
hash -t python
# List all hashed commands
hash -l
PARAMETERS
-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.
CAVEATS
Shell built-in; behavior and available options vary by shell (bash, zsh, ksh each implement their own version). The hash table becomes stale if a hashed command's file is moved or removed. Run `hash -r` after installing software or modifying PATH. Only affects the current shell session, not child processes.
HISTORY
hash has been part of Unix shells since the Bourne shell. POSIX only mandates the `-r` option; bash extends it with `-p`, `-d`, `-t`, and `-l` for finer control over the command path cache.