type command is used to display information about the command type. It will show you how a given command would be interpreted if typed on the command line.
In this article, we will explain how to use the Linux
How to Use the type Command
type is a shell builtin in Bash and other shells like Zsh and Ksh. Its behavior may be slightly different from shell to shell. We will cover the Bash builtin version of
The syntax for the
type command is as follows:
type [OPTIONS] FILE_NAME...
For example, to find the type of the
wc command, you would type the following:
The output will be something like this:
wc is /usr/bin/wc
You can also provide more than one arguments to the
type sleep head
sleep is /bin/sleep head is /usr/bin/head
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)
Here are a few examples:
type -t grep
In my system
grep is aliased to
type -t rvm
rvm is a tool (function) for installing, managing, and working with multiple Ruby environments:
type -t echo
echo is a shell builtin in Bash and other shells like Zsh and Ksh:
type -t cut
cut is an executable file :
type -t for
for is a reserved word in Bash:
Display all locations that contain the command
To print all matches, use the
type -a pwd
The output will show you that
pwd is a shell builtin but it is also available as a standalone
pwd is a shell builtin pwd is /bin/pwd
-a option is used, the type command will include aliases and functions, only if the
-p option is not used.
Other type command options
-p option will force
type to return the path to the command only if the command is an executable file on the disk:
For example, the following command will not display any output because the
pwd command is a shell builtin.
type -p pwd
-p, the uppercase
-P option tells
type to search the
PATH for an executable file on the disk even if the command is not file.
type -P pwd
pwd is /bin/pwd
-f option is used,
type will not look up for shell functions, as with the command builtin.
type command will show you how a specific command will be interpreted if used on the command line.
If you have any questions or feedback, please leave a comment below.