Mastering the Linux ‘type’ Command: Identify Command Types and Paths
Learn how the Linux ‘type’ command reveals whether a given name is an alias, keyword, function, builtin, or external file, and discover its useful options—such as -a, -f, -p, -t, and -P—to control search behavior and output paths.
type: Display Command Type
Function Description
The type command shows the type of a specified command, indicating whether it is an internal (builtin, function, alias, keyword) or external command.
Syntax
type [-afptP] name [name ...]Options
-a : Search the PATH and display all executable files matching name; also show aliases, keywords, functions, and builtins if -p is not used.
-f : Exclude shell functions from the search.
-p : Return nothing unless type -t name yields “file”; otherwise, search PATH and return the executable path.
-t : Output a single word describing the type (alias, keyword, function, builtin, file) or empty if not found.
-P : Even if name is an alias, builtin, or function, still search PATH and return the external executable path.
Parameters
name: One or more command names to be examined.
Command Types
alias : Alias command.
keyword : Shell reserved word.
function : Shell function.
builtin : Built‑in command.
file : External executable file.
unfound : Not found.
Example Usage
// Alias example
# type ls
ls is aliased to `ls --color=auto`
// Keyword example
# type if
if is a shell keyword
// Builtin example
# type cd
cd is a shell builtinSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
