type vs which vs command -v — Find What a Command Really Is

Resolve whether a command is an alias, shell builtin, function, or executable — and see every copy on your PATH — with the right tool for each job.

LinuxshellcommandpathcliLow risk
Run type -a cmdname to reveal what a command is and all its matches; use which -a for executable paths only and command -v in scripts for portability.

01Command

Command
$ type -a ll && which -a python3 && command -v git

02What it does

These three look similar but answer different questions: type knows about the shell itself (aliases, functions and builtins) and reports matches in the order bash would actually use them; which only searches PATH for executable files and knows nothing about aliases — a classic trap when your alias shadows a binary; command -v is the POSIX-standard, scripting-safe version that prints just the path or name and fails silently when not found, making it the correct choice inside scripts. type -a is the one to reach for when 'the command does something unexpected', because it lists every definition the shell would consider.

03Risk

RiskLow risk
!Warning: which can mislead you when an alias or function overrides a binary — it will happily report the binary while your shell runs the alias; trust type -a for interactive diagnosis.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • bash(1) — Linux manual page
    Arch Linux · community · 2026-09-17
    Evidence: Documents the type builtin (resolves aliases, builtins, functions and files in lookup order), and command -v as the POSIX-portable lookup.
  • which(1) — Linux manual page
    Arch Linux · community · 2026-09-17
    Evidence: which locates executables in PATH; -a lists all matches instead of only the first.

Last verified: 2026-09-18 · Category: Developer