type command in Linux with Examples
The type command in Linux is a useful utility for identifying how the shell will interpret a given command. It provides information on whether a command is a shell built-in, external binary, function, or alias, helping users understand the source of the command and its behavior. The command is particularly helpful when troubleshooting or exploring system utilities, as it reveals whether a command is being executed as an alias, keyword, or a binary file from the disk.
Syntax
type [Options] command names
Basic 'type' command Example

Key Options of the type Command
1. -a: Show All Locations (Aliases, Keywords, Functions, Executable Files)
This option is used to find out whether it is an alias, keyword or a function and it also displays the path of an executable, if available.
Example:
type -a pwd

2. -t: Display a Single Word Indicating Command Type
The '-t' option will return a single word that describes the type of the command. It simplifies the output by focusing only on the category of the command: alias, keyword, builtin, function, or file.
Example:
type -t pwd
type -t cp
type -t ls
type -t while

- alias: if command is a shell alias
- keyword: if command is a shell reserved word
- builtin: if command is a shell builtin
- function: if command is a shell function
- file: if command is a disk file
3. -p: Display the Path to the Executable File
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.
Example:
type -p dash

If dash exists as an executable on the disk, it shows the path where it's located.
Conclusion
The 'type' command in Linux is a versatile tool that helps users and system administrators gain insights into how commands are interpreted by the shell. 'type' makes it easy to understand the source of a command’s behavior, whether you’re trying to figure out if a command is a built-in or external executable, or debugging an alias.