Unix/Linux Go Back    

UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

How does the Debian Alternatives systems work ?

UNIX for Dummies Questions & Answers

alternative, debian

Thread Tools Search this Thread Display Modes
Old Unix and Linux 06-08-2016   -   Original Discussion by sreyan32
sreyan32's Unix or Linux Image
sreyan32 sreyan32 is offline
Registered User
Join Date: Nov 2012
Last Activity: 12 February 2018, 9:53 AM EST
Posts: 55
Thanks: 25
Thanked 0 Times in 0 Posts
Debian How does the Debian Alternatives systems work ?

Alright I have read all the documentation regarding the alternatives system present in Debian. And I still can't get my head around it.

Correct me if I am wrong, the /etc/alternatives directory is nothing but a directory of symlinks right ? So for example java will have a symlink pointing to the actual executable to be executed when java is called from the command line. Like it is described in this answer in SO (What exactly does `update-alternatives` do? - Ask Ubuntu).

So let me get this straight, some programs that has a generic name is assigned a symlink in the /etc/alternatives/ directory. So like /usr/bin/java is assigned a symlink in /etc/alternatives called java which points to the actual file. So it is <generic_name>---> <alternatives_symlink> ---> <actual_file> right ?
But I have seen systems like <alternatives_symlink> ---> <generic_name> ---> <actual_file>. Isn't that the wrong implementation of the alternatives system ?

How are priorities maintained in the alternatives system ?
I mean a symlink can only point to one file at a time so then how can the alternatives system keep track of multiple programs under the same name ? For example, java maybe openjdk or oracle jdk. So once I have uninstalled oracle jdk I want the symlink in the alternatives directory to point to openjdk, how does this happen automatically ?

How to master and slave links work ?
What's the intuition behind them ? For example lets take the following command example taken from this post (How to switch GCC version using update-alternatives – Code Yarns)

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8

So the above command is telling gcc to point to version 4.8, also it says that along with gcc please update g++. Right ? So AFAIK master and slave links signify that if the master is updated please update the slave also. But here both of them ARE UPDATED simultaneously. So why am I saying that update slave if master is updated even when IT HAS ALREADY BEEN UPDATED.

Also lets say I change the gcc alternatives to something else next what will the slave be updated to ? I mean this is really needlessly confusing.

Taking a line from the Ubuntu documentation(Ubuntu Manpage:

update-alternatives - maintain symbolic links determining default
The generic name is not a direct symbolic link to the selected
alternative. Instead, it is a symbolic link to a name in the
alternatives directory, which in turn is a symbolic link to the actual
file referenced. This is done so that the system administrator's
changes can be confined within the /etc directory: the FHS (q.v.) gives
reasons why this is a Good Thing.

Why is good that the alternatives is confined to the /etc/ directory ? Didn't find anything FHS.

Referenced Documentation:
Ubuntu Manpage:

DebianAlternatives - Debian Wiki
Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sed -f alternatives? twoblink Shell Programming and Scripting 9 04-26-2012 12:49 PM
From Systems Admin to Systems Eng. svalenciatech What is on Your Mind? 0 03-21-2011 10:13 PM

All times are GMT -4. The time now is 01:40 PM.