alternatives on RHEL 6 using update-alternatives

When multiple types/versions of software can be installed on a system, the alternatives system can be used. Some examples of software that use alternatives are:

  • java (openjdk/oracle)
  • mta (sendmail/postfix/exim)
  • php (different versions)
  • zabbix-server (using mysql/psql)
  • gpg (using gpg/pgp)

Alternatives can be added to the system:

alternatives --install <link> <name> <path> <priority>

  1. link - refers to the path the system uses to access the facility, common to all alternatives.
  2. name - is an identifier common to all alternatives.
  3. path - is a path to the unique altenative.
  4. priority - a number to indicate what alternative may be used when using "auto". Higher means it will be selected.

When adding an alternative, sometimes "slaves" are required. For example, these "masters" and "slaves" relate to eachother:

  • postfix - mailq
  • java - keytool

Alternatives can be selected in "manual" or "auto" mode. Manual means an alternative is selected and it will use an alternative until another one is selected. Auto means the alternatives system will automatically select the alternatives with the hightest priority. This means the selected alternative can change when a new alternative is added.
By default "auto" is used. Package upgrades may cause a switch. Auto does have the benefit that vendor updates will cause a desirable effect. When removing an alternative (for example by removing a package that supplied the alternative software) the next preferred alternative will be selected, which is nice.