In this article we are going to shows how to use type command in Linux Terminal. If you want to learn about type command in Linux with Examples then this post is ideal for you.
The type is a command-line utility that is used to show information about a Linux command and how its argument would be translated if used as commands. The type command is also used to find out whether it is built-in or external binary file.
Linux is an operating system, like Windows OS, iOS, and Mac OS. It is one of the most popular operating system on the planet, Android is also powered by Linux OS(operating system).
Linux OS(operating system) is also distributed under an open source license. Open source following these points :
- Freely to run the program, for any purpose.
- Free to study how the program works.
- Freely to re-distribute copies so you can help your friends.
- Free to distribute copies of your modified versions to others.
The type Command in Linux
In the Linux, the basic syntax of the type command is show as below:
$ type [OPTIONS] FILE_NAME...
For an example:
$ type cd
The above command display a output as below:
Output
cd is a shell builtin
The type command also allows you to provide multiple arguments at once:
type wc cd
Output
wc is /usr/bin/wc
cd is a shell builtin
Options of type Command
Display single word information of a Linux command
The -t
option is used to tells the type
command to display a single word information of the give command which can be one of the following:
- alias (shell alias)
- function (shell function)
- builtin (shell builtin)
- file (disk file)
- keyword (shell reserved word)
Examples
1. Alias
$ type -t ls
Output
alias
2. Function
$ type -t rvm
Output
function
3. Builtin
$ type -t cd
Output
builtin
4. File
$ type -t mkdir
Output
file
5. Keyword
$ type -t if
Output
keyword
Display all locations that contain the command
To display all information about a Linux command, use -a option with type command as below:
$ type -a pwd
Output
pwd is a shell builtin
pwd is /bin/pwd
Other options of type command
The -p
option is used to force type
command to return the path to the given command only if the command is an executable file on the disk:
$ type -p pwd
The above command will not display any output because the pwd
command is not a file executable command. It is a shell builtin coomand.
Now use the uppercase -P
option that is used to tells type
command to search the Path
of an executable file on the disk even if the given command is not file.
$ type -P pwd
Output
pwd is /bin/pwd
That’s all
If you face any error and issue in above steps , please use comment box below to report.
If our tutorials helped you, please consider buying us a coffee. We appreciate your support!
Thank you for your support.