The type command is used to show information about the command
type and how its argument would be interpreted if typed on the command line. It is also used to find out whether it is built-in or external binary file. In this article, we will explain how to use the Linux
How to Use the
Below is the basic syntax for the
type [OPTIONS] FILE_NAME...
For example, to find the
type of the cd command, you would
type the following:
It will show output as following:
cd is a shell builtin
You can pass the multiple arguments to the
type command by space separated:
type sleep cd
sleep is /bin/sleep cd is a shell builtin
Use the option
-t with type to find out whether it is an alias, keyword or a function, it can be one of the following single word output:
Following are the examples:
type -t grep
Here ls is aliased to
type -t rvm
rvm is a tool (function) for installing, managing, and working with multiple Ruby environments:
type -t cd
cd is a shell builtin in Bash and other shells like Zsh and Ksh:
type -t cut
cut is an executable file:
type -t while
while is a reserved word in Bash:
Display all locations that contain the command
-a is used to display all matches and the path of an executable, if available.
type -a pwd
pwd is a shell builtin pwd is /bin/pwd
In above output showing that
pwd is shell builtin and it is also available as a standalone
type command options
-p option with to force
type command to print the path to the command 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 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
Type command will not look up for shell functions when the
-f option is used.
type command will show you information about specific command type and how it will interpreted if used on the command line.
If you have any questions or feedback, please leave a comment below.