When to use type
Use type to understand how the current shell resolves a command name. It can reveal aliases, functions and builtins that a simple executable-path search would miss, which helps explain surprising behaviour.
Syntax
type [PARAMETERS] NAME…Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Find out what will launch
type sshThe shell reports how it would interpret the SSH command name.
Show all definitions of a command
type -a printfAll known command forms are listed where the shell supports this option.
Find external executable
type -P python3Bash searches for an executable path rather than reporting a function or builtin.
Notes and limitations
- The builtin command takes into account the functions and aliases of the current shell.
- For portable scripts, check key support or use command -v.
Common questions and troubleshooting
Why does type disagree with which?
The shell can resolve aliases, builtins and functions before searching executable paths. which often inspects a narrower path-based view.
Do these options work in every shell?
No. type is commonly a shell builtin and its options vary. Check the active shell's help before using it in portable scripts.
Further help
Options vary by version and distribution. Check the installed documentation with this command: help type.