/etc/alternatives

Stuart Sears stuart at sjsears.com
Wed Aug 11 06:56:23 UTC 2004


On Wednesday 11 August 2004 04:05, Ryan Golhar wrote:
> I installed the java SDK RPM from java.sun.com.
>
> Recently, however, I noticed that /usr/bin/java, /usr/bin/javac, and
> /usr/bin/jar point to scripts in /etc/alternatives.
>
> I figured out that these replacements are from libgcj.  It doesn't look
> like I can until this other RPM as there are others that depend on it.
> My question is why do they replace a legitimate program (java) with a
> script that doesn't do anything.  That just seems to break everything.
> I remove the link so the real java program is picked up correctly.  Does
> anyone know what this is for and why its done?
the alternatives system is there to allow you to install several 
services/packages that provide the same functionailty ( and very often the 
same program names) and switch between them without uninstalling either.
Its most common use is to switch between sendmail and postfix, but links can 
be set up to cater for any package at all.
How does it work?
okay, the postfix/sendmail example:
many programs look for a 'sendmail' binary when they want to, well, send mail.
unfortunately both  the sendmail and postfix packages normally provide a 
binary of this name, which means that if you want to switch from sendmail to 
postfix you would normally have to uninstall sendmail and then install 
postfix instead, which will involve at the very least a certain amount of 
downtime. On a Redhat system, these packages have been 'hacked' to provide 
sendmail.sendmail / sendmail.postfix (among other) binaries, so that this 
problem no longer exists, but how do apps know which one to call?
a series of symbolic links are set up:
/usr/sbin/sendmail -> /etc/alternatives/mta -> /usr/sbin/sendmail.postfix
why three links instead of two?
well, the other programs with clashing names also have to be dealt with, This 
is done using a series of 'slave' links which are automtically switched over 
when you change the master 'mta' link.
try the alternatives command:
[root at behemoth root]# alternatives --display mta
mta - status is manual.
 link currently points to /usr/sbin/sendmail.postfix
/usr/sbin/sendmail.sendmail - priority 90
 slave mta-pam: /etc/pam.d/smtp.sendmail
 slave mta-mailq: /usr/bin/mailq.sendmail
 slave mta-newaliases: /usr/bin/newaliases.sendmail
 slave mta-rmail: /usr/bin/rmail.sendmail
 slave mta-rsmtp: (null)
 slave mta-runq: (null)
 slave mta-sendmail: /usr/lib/sendmail.sendmail
 slave mta-mailqman: /usr/share/man/man1/mailq.sendmail.1.gz
 slave mta-newaliasesman: /usr/share/man/man1/newaliases.sendmail.1.gz
 slave mta-aliasesman: /usr/share/man/man5/aliases.sendmail.5.gz
 slave mta-sendmailman: /usr/share/man/man8/sendmail.sendmail.8.gz
/usr/sbin/sendmail.postfix - priority 30
 slave mta-pam: /etc/pam.d/smtp.postfix
 slave mta-mailq: /usr/bin/mailq.postfix
 slave mta-newaliases: /usr/bin/newaliases.postfix
 slave mta-rmail: /usr/bin/rmail.postfix
 slave mta-rsmtp: (null)
 slave mta-runq: (null)
 slave mta-sendmail: (null)
 slave mta-mailqman: /usr/share/man/man1/mailq.postfix.1.gz
 slave mta-newaliasesman: /usr/share/man/man1/newaliases.postfix.1.gz
 slave mta-aliasesman: /usr/share/man/man5/aliases.postfix.5.gz
 slave mta-sendmailman: /usr/share/man/man1/sendmail.postfix.1.gz
Current `best' version is /usr/sbin/sendmail.sendmail.

you switch between the two systems with 
alternatives --set mta /usr/sbin/sendmail.sendmail
(or postfix or any other that you have set up this way)
or by using 
redhat-switch-mail
wich will change the master link and the slaves will follow along like sheep.

any help?
ps if you want to know the command that set these things up, look at the 
install scripts for sendmail

rpm -qp --scripts sendmail

HTH
-- 
Stuart Sears RHCE, RHCX





More information about the redhat-list mailing list