which toont het volledige pad van het uitvoerbare bestand dat de shell zou uitvoeren.
which python3
# /usr/bin/python3
which nginx
# /usr/sbin/nginx
| Optie | Betekenis |
|---|---|
-a | Toon alle overeenkomsten in $PATH |
Welke Python wordt gebruikt:
which python python3 python3.11
Alle exemplaren:
which -a python3
# /usr/bin/python3
# /usr/local/bin/python3
Controleren of commando beschikbaar is:
if ! which rsync &>/dev/null; then
echo "rsync niet gevonden"
exit 1
fi
which vindt alleen externe programma's in $PATH. Het vindt geen shell-aliassen, ingebouwde commando's of functies. Gebruik type daarvoor:
type ls # ls is aliased to 'ls --color=auto'
type cd # cd is a shell builtin
Als een commando anders gedraagt dan verwacht, controleer met which commando of je wel het juiste binaire bestand gebruikt.