Fundamentals 4 min read

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.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux’s type Command: Find Command Types, Paths, and Aliases

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] name

Common 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 cd

Typical output:

cd is a shell builtin

External executable

type ls

Typical output:

ls is /bin/ls

Alias

type ll

Typical 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/ls

Listing 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/python

Practical 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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxShelltype command
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.