which, type, whereis in Linux: where a command lives
Updated July 3, 2026
which, type and whereis answer where a command lives and what it is.
Common cases
which bash # the path to the program file in PATH
type cd # cd is a shell builtin
type ll # shows if it is an alias
whereis ls # the program and its man pageHow it works: file, alias or builtin
Not every command is a program on disk.
cdis built into the shell (a builtin),llis usually an alias, andlsis a program file on thePATH.whichonly looks for a file in thePATHdirectories and knows nothing about builtins or aliases.typedoes: it tells you exactly what a command is, and that is the most honest answer.whereisalso finds themanpage and the sources. When it is unclear why the wrong command runs, start withtype.
Used in
You need this in the lessons Finding files and Getting help. The theory is the chapter Getting help: man and --help.
See also
The locate command, The find command, The PATH variable.
Try it
Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.