Shell and environment

Command type

Show command type

Linux · Bash examples · commands run on the selected server

When to use type

Use type to understand how the current shell resolves a command name. It can reveal aliases, functions and builtins that a simple executable-path search would miss, which helps explain surprising behavior.

Syntax

type [PARAMETERS] NAME…

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-a
Show all available name definitions in Bash.
-t
Output type: builtin, function, alias or file.
-P
Search for executable file via PATH in Bash.

Usage examples

Find out what will launch

type ssh

The shell reports how it would interpret the SSH command name.

Show all definitions of a command

type -a printf

All known command forms are listed where the shell supports this option.

Find external executable

type -P python3

Bash searches for an executable path rather than reporting a function or builtin.

Notes and limitations

  • The builtin command takes into account the functions and aliases of the current shell.
  • For portable scripts, check key support or use command -v.

Common questions and troubleshooting

Why does type disagree with which?

The shell can resolve aliases, builtins and functions before searching executable paths. which often inspects a narrower path-based view.

Do these options work in every shell?

No. type is commonly a shell builtin and its options vary. Check the active shell's help before using it in portable scripts.

Further help

Options vary by version and distribution. Check the installed documentation with this command: help type.