type Command in Linux: Show Command Type and Location

The type command shows how the current shell would interpret a name entered on the command line. Depending on the shell, it can identify aliases, functions, builtins, keywords, and executable files.
This article explains how to use the type builtin, with Bash examples and notes where Zsh and other popular shells behave differently.
How to Use the type Command
type is a shell builtin in Bash, Zsh, and Ksh, but the supported options and output format are not identical across shells. The examples below use Bash syntax, and option availability should be checked in your current shell with help type, type --help, or the shell documentation.
The syntax for the type command is as follows:
type [OPTIONS] NAME...For example, to find the type of the wc command
, you would type the following:
type wcThe output will be something like this:
wc is /usr/bin/wcYou can also provide more than one argument to the type command:
type sleep headThe output will include information about both sleep
and head
commands:
sleep is /bin/sleep
head is /usr/bin/headCommand Types
The option -t tells type to print a single word describing the type of the command which can be one of the following:
- alias (shell alias)
- function (shell function)
- builtin (shell builtin)
- file (disk file)
- keyword (shell reserved word)
The exact wording may differ between shells. For example, Zsh can report command where Bash reports file.
Here are a few examples:
Alias
Terminaltype -t grepIn my system
grepis aliased togrep --color=auto:outputaliasFunction
Terminaltype -t rvmrvmis a tool (function) for installing, managing, and working with multiple Ruby environments:outputfunctionBuiltin
Terminaltype -t echoechois a shell builtin in Bash and other shells like Zsh and Ksh:outputbuiltinFile
Terminaltype -t cutcutis an executable file:outputfileKeyword
Terminaltype -t forforis a reserved word in Bash:outputkeyword
Display all locations that contain the command
To print all matches, use the -a option:
This option is supported by Bash and Zsh, but the order and wording of the results may differ.
type -a pwdThe output will show you that pwd
is a shell builtin but it is also available as a standalone /bin/pwd executable:
pwd is a shell builtin
pwd is /bin/pwdWhen -a is used without -p, type can include aliases and functions in addition to executable files.
Additional Options
In Bash and Zsh, the -p option prints the path only when the resolved name is an executable file on disk:
For example, this command may print nothing because pwd is usually resolved as a shell builtin.
type -p pwdIn Bash, the uppercase -P option tells type to search PATH for an executable file on disk even when the name also resolves to a builtin or function. This option may not be available in all shells.
type -P pwd/bin/pwdThe -f option tells type to skip shell functions during lookup. Support for this option may vary by shell.
Quick Reference
| Command | Description |
|---|---|
type name | Show how a name would be interpreted |
type name1 name2 | Check multiple names at once |
type -t name | Print the type word only (alias, function, builtin, file, keyword) |
type -a name | Show all locations that match the name |
type -p name | Print the path only if it is a disk file |
type -P name | Force a PATH search even for builtins |
type -f name | Ignore shell functions when looking up the name |
FAQ
What is the difference between type and which?which searches only PATH for executable files. type is a shell builtin that also identifies aliases, functions, keywords, and other builtins — making it more complete for understanding how the shell will resolve a name.
What does it mean when type says a command is a builtin?
The command is handled directly by the shell without forking a new process. Examples include echo, cd, pwd, and type itself.
Why does type -p return nothing for some commands?-p only prints a path when the command is an executable file on disk. Builtins, functions, aliases, and keywords produce no output with -p.
Does the type command behave the same in Bash and Zsh?
No. type is a shell builtin, so supported options and output format can differ between Bash, Zsh, and other shells. If you need a portable way to check whether a command exists in a script, prefer command -v name.
Can I use type in a script to check if a command exists?
Yes. Use type -P command or type command > /dev/null 2>&1 and check the exit code. Exit code 0 means the command was found; a non-zero exit code means it was not.
Conclusion
The type command shows how the shell will interpret a given name — whether it resolves to a builtin, alias, function, keyword, or an executable on disk. It is more thorough than which for understanding shell name resolution.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page