Master Linux’s type Command: Find Command Types, Paths, and Aliases
This guide explains how to use the Linux type command to identify whether a command is built‑in, external, or an alias, display its location, retrieve its full path, and list all possible occurrences, with clear examples for each option.
Overview
The type builtin reports how the shell would interpret a given name. It distinguishes between shell built‑ins, functions, aliases, and external executables, and can reveal the absolute pathname of the executable.
Syntax
type [options] nameCommon options
-a: display every location that matches name in
$PATH -t: output only the type (e.g., alias, builtin, file, function) -P: print the absolute pathname of the command that would be executed, ignoring functions and built‑ins
Inspecting different kinds of commands
Shell built‑in
type cdTypical output:
cd is a shell builtinExternal executable
type lsTypical output:
ls is /bin/lsAlias
type llTypical output (when ll is defined as an alias):
ll is aliased to 'ls -alF'Retrieving the full pathname
Use -P to obtain the resolved absolute path, even for aliases.
type -P ls /bin/ls type -P ll /bin/lsListing all occurrences in $PATH
The -a flag shows every matching file found in the search path.
type -a python python is /usr/bin/python python is /usr/local/bin/pythonPractical notes
When a name is both an alias and an external command, type reports the alias first; use -P to bypass the alias.
The -t option is useful in scripts to branch logic based on the command type.
All output is designed for human reading; for machine parsing, combine -t with other options.
Signed-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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
