LinuxCommandLibrary

hash

Shell built-in command path cache manager

TLDR

Show command hash table

$ hash
copy
Clear hash table
$ hash -r
copy
Add command to hash
$ hash -p [/usr/local/bin/mycommand] [mycommand]
copy
Remove command from hash
$ hash -d [command]
copy
Show path for command
$ hash -t [command]
copy
List all hashed commands in reusable format
$ hash -l
copy

SYNOPSIS

hash [options] [name...]

DESCRIPTION

hash is a shell built-in command that manages the hash table of recently executed commands. The shell uses this table to cache the full filesystem paths of commands, avoiding repeated searches through the PATH directories.
When a command is first executed, the shell locates it by searching each directory in PATH. The resolved path is then stored in the hash table so subsequent invocations skip the search entirely, improving performance.
The hash table can become stale if commands are moved, renamed, or if new versions are installed in higher-priority PATH directories. Running `hash -r` clears the table, forcing the shell to re-resolve paths on next use. This is commonly needed after installing new software or modifying PATH.

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 varies by shell. Hash becomes stale if commands move. Use hash -r after PATH changes or software installation. Only affects current shell session.

HISTORY

The hash command has been part of Unix shells since the Bourne shell. It provides manual control over the command path caching mechanism that shells use for performance.

SEE ALSO

type(1), which(1), command(1)

> TERMINAL_GEAR

Curated for the Linux community

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

$54.00
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

$54.00
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99