Which, Whereis & Type Commands
Locate commands and executables with which, whereis, and type.
calendar_today2025-12-01
local_offerwhich, whereis, type, locate
WHICH - Find command in PATH
which python
which python3
which node
which -a python
which ls bash vim
Common uses
which docker > /dev/null && echo "Docker installed"
which python
which python3
WHEREIS - Locate binary, source, man pages
whereis python
whereis -b python
whereis -m python
whereis -s python
Options
whereis -B /usr/bin -f python
whereis -u python
TYPE - Describe command type
type ls
type cd
type python
type -a python
type -p python
type -t ls
type -t cd
type -t python
Command types
alias - Command alias
builtin - Shell builtin
file - External program
function - Shell function
keyword - Shell keyword
COMMAND - Run command directly
command ls
command -v python
command -V python
Comparison
which ls
whereis ls
type ls
command -v ls
Check if command exists
if which python3 > /dev/null 2>&1; then
echo "Python 3 is installed"
fi
if type python3 > /dev/null 2>&1; then
echo "Python 3 is available"
fi
if command -v python3 > /dev/null 2>&1; then
echo "Python 3 is available"
fi
Find alternative versions
which -a python python2 python3
update-alternatives --list python
ls -l /usr/bin/python*
Script usage
#!/bin/bash
for cmd in git node npm; do
if ! command -v $cmd > /dev/null; then
echo "Error: $cmd is not installed"
exit 1
fi
done
echo "All dependencies satisfied"
Environment investigation
echo $PATH
which python
type -a python
whereis python
type python
ls -l $(which python)
Troubleshooting
which command-name
echo $PATH
type -a command-name
which -a command-name
type command-name
alias | grep command-name
which python && python --version
which node && node --version
Best practices
command -v docker > /dev/null || exit 1
/usr/bin/python3 script.py
python --version
type -a command-name