type
shell builtinLinux/Unix
The type command is one of the most frequently used commands in Linux/Unix-like operating systems. type Display information about command type
Quick Reference
Command Name:
type
Category:
shell builtin
Platform:
Linux/Unix
Basic Usage:
type [options] [arguments]
Common Use Cases
Syntax
type [-afptP] name [name ...]
Options
Option | Description |
---|---|
-a |
Display all locations containing an executable named NAME |
-f |
Suppress shell function lookup |
-p |
Display the name of the disk file that would be executed, or nothing if 'type -t NAME' would not return 'file' |
-P |
Force a PATH search for each NAME, even if it is an alias, builtin, or function, and returns the name of the disk file that would be executed |
-t |
Output a single word: 'alias', 'keyword', 'function', 'builtin', 'file' or nothing if TYPE is not found |
Examples
How to Use These Examples
The examples below show common ways to use the type
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
Check the type of a common command
type ls
Check if a command is a shell builtin
type cd
Check if a command exists
type nonexistentcommand
Advanced Examples:
Get all locations of a command in PATH
type -a python
Get the file path of a command
type -p grep
Show the command as a string that would be executed
type -t bash