Linuxlab

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 page

How it works: file, alias or builtin

Not every command is a program on disk. cd is built into the shell (a builtin), ll is usually an alias, and ls is a program file on the PATH. which only looks for a file in the PATH directories and knows nothing about builtins or aliases. type does: it tells you exactly what a command is, and that is the most honest answer. whereis also finds the man page and the sources. When it is unclear why the wrong command runs, start with type.

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.