The type command in Linux shows how the current shell would interpret a name typed on the command line. It identifies aliases, functions, builtins, keywords, and executable files — giving you the full picture of what will actually run.
type is a shell builtin in Bash, Zsh, and Ksh. Supported options and output format are not identical across shells.
The syntax is:
bashtype [OPTIONS] NAME...
Check a single command:
bashtype wc # wc is /usr/bin/wc
Check multiple names at once:
bashtype sleep head
type vs which. which searches only PATH for executable files. type understands the full shell resolution order: aliases first, then functions, builtins, keywords, and finally PATH executables. This matters in practice: if grep is aliased to grep --color=auto, then type grep returns alias — because that is what the shell will actually run, not the binary.
Use -t to print a single descriptive word:
bashtype -t grep # aliastype -t rvm # functiontype -t echo # builtintype -t cut # filetype -t for # keyword
In Zsh, the word command may appear where Bash reports file. The exact wording depends on the shell.
Builtins are handled directly by the shell without forking a new process. echo, cd, pwd, and type itself are all builtins. This is why cd cannot be replaced by an external script — it must run inside the current shell process to actually change the working directory.
-a shows every location where a name is found, including aliases, functions, and disk executables:
bashtype -a pwd
pwd is a shell builtinpwd is /bin/pwd
This reveals that pwd exists as both a builtin and a standalone executable on PATH. Useful when an alias or function is shadowing an executable you did not expect.
-p prints the path only if the resolved name is a disk file. It produces no output for builtins, aliases, or functions:
bashtype -p pwd # no output — pwd resolves as a builtin first
-P (Bash only) forces a PATH search even when a builtin or function with the same name exists:
bashtype -P pwd # /bin/pwd
Checking command existence in scripts. Use type with exit code checking to test whether a command is available:
bashtype command > /dev/null 2>&1 && echo "found" || echo "not found"
For the most portable approach across shells, command -v name is the POSIX standard alternative and works reliably in Bash, Zsh, Dash, and sh.
Use type name to see exactly how your shell will resolve a command before running it. Use -a to reveal aliases or functions that shadow executables, -P to force a PATH search, and command -v for portable existence checks in scripts. Leave a comment below if you run into any issues.