which
28-10-2026 door Bernard in
Geen categorie
which toont het volledige pad van het uitvoerbare bestand dat de shell zou uitvoeren.
Basisgebruik
which python3
# /usr/bin/python3
which nginx
# /usr/sbin/nginx
Opties
| Optie | Betekenis |
|---|---|
-a |
Toon alle overeenkomsten in $PATH |
Voorbeelden
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
Beperking
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
Tip
Als een commando anders gedraagt dan verwacht, controleer met which commando of je wel het juiste binaire bestand gebruikt.
Reactie? Stuur ons een bericht via ons contactformulier.