Choose Which Version of a Program Runs by Default with update-alternatives
Note#200
notes
Published
2026-03-10
Debian’s update-alternatives manages symlinks in /etc/alternatives/ so that several programs providing the same functionality (e.g., php, java) can coexist, and you pick which one the generic name points to.
The last number is the priority. Highest priority wins in auto mode.
Switch
# Interactive pickersudo update-alternatives --config php# Or set it directlysudo update-alternatives --set java /usr/lib/jvm/java-21-openjdk-amd64/bin/java
Inspect
# Show current choice and all registered alternativesupdate-alternatives--display php# List all managed groupsupdate-alternatives--get-selections