Multiple applications with the same name can be used with alternatives.
For example, if you want to install several versions of gcc, alternatives support
switching between multiple versions with one command.
- List which versions of gcc are installed
- Add several alternatives for gcc
- Select which version of gcc should be selected
- Add alternatives for g++, i486-linux-gnu-gcc and i486-linux-gnu-g++
ls /usr/bin/gcc*
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 40
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.1 30
sudo update-alternatives --config gcc
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 40
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.1 30
update-alternatives --config g++
update-alternatives --install /usr/bin/i486-linux-gnu-gcc i486-linux-gnu-gcc /usr/bin/i486-linux-gnu-gcc-4.4 40
update-alternatives --install /usr/bin/i486-linux-gnu-gcc i486-linux-gnu-gcc /usr/bin/i486-linux-gnu-gcc-4.1 30
update-alternatives --config i486-linux-gnu-gcc
update-alternatives --install /usr/bin/i486-linux-gnu-g++ i486-linux-gnu-g++ /usr/bin/i486-linux-gnu-g++-4.4 40
update-alternatives --install /usr/bin/i486-linux-gnu-g++ i486-linux-gnu-g++ /usr/bin/i486-linux-gnu-g++-4.1 30
update-alternatives --config i486-linux-gnu-g++
Internally, the alternatives are handled as symbolic links and the link is changed, if the config is updated.