Linux type Command
Learn Linux type Command with examples
Published
Linux type Command
In Linux, we can use “type” command is used to display information about the command type.
It is also used to find out whether it is built-in or external binary file.
type Command Syntax
>> type [Options] command-name
type Command Example
>> type ls
ls is aliased to `ls --color=auto'
type Command with Multiple Commands
>> type sleep head
sleep is hashed (/usr/bin/sleep)
head is /usr/bin/head
type -a Command
The output will show you that pwd is a shell builtin but it is also available as a standalone /bin/pwd executable
>> type -a pwd
pwd is a shell builtin
pwd is /usr/bin/pwd
pwd is /bin/pwd
type -p Command
This option displays the name of the disk file which would be executed by the shell. It will return nothing if the command is not a disk file.
>> type -p dash
type -t Command
The option -t tells type to print a single word describing the type of the command which can be one of the following.
Command | Description |
alias | if command is a shell alias |
builtin | if command is a shell builtin |
function | if command is a shell function |
file | if command is a disk file |
keyword | if command is a shell reserved word |
Examples:
>> type -t pwd
>> type -t cp
>> type -t ls
>> type -t wc
>> type -t while
- Alias
In my system grep is aliased to grep –color=auto:
>> type -t grep
alias
- Builtin
echo is a shell builtin in Bash and other shells like Zsh and Ksh:
>> type -t echo
builtin
- File
cut is an executable file
>> type -t cut
file
- Function
rvm is a tool (function) for installing, managing, and working with multiple Ruby environments:
>> type -t rvm
- Keyword
for is a reserved word in Bash
>> type -t for
keyword