How does the Debian Alternatives systems work ?


 
Thread Tools Search this Thread
# 1  
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.

First,
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 ?

Second,
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 ?

Thirdly,
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)

Code:
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.

Lastly,
Taking a line from the Ubuntu documentation(Ubuntu Manpage:

update-alternatives - maintain symbolic links determining default
)-:
Quote:
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
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Alternatives to Expect

Are there any other alternatives to using Expect script? Can functionality provided by Expect be achieved by any other scripting language? (7 Replies)
Discussion started by: indianya
7 Replies

2. UNIX for Advanced & Expert Users

SSH alternatives

Hi, I am using SSH to execute unix commands on remote machines. But, SSH will be diabled soon and I am looking for other alternatives to execute remote scripts/commands, without SSH . any suggestions or workarounds with out SSH for remote program executions ? Thanks in advance. (4 Replies)
Discussion started by: talashil
4 Replies

3. Shell Programming and Scripting

Sed -f alternatives?

I have a list of items (control file) that I want to substitute in a text file, and it's BIG. The file has two items, the original, and the new: A B B C D E The file has something like 10,000 entries. So in the oldfile.txt, I'd like to basically make all these expression matched... (9 Replies)
Discussion started by: twoblink
9 Replies

4. What is on Your Mind?

From Systems Admin to Systems Eng.

I have been wondering how do Systems Administrators do the jump into Systems Engineering? Is it only a matter of time and experience or could I actually help myself get there? Opinions? Books I could read? Thanks a lot for your help! (0 Replies)
Discussion started by: svalenciatech
0 Replies

5. Red Hat

Alternatives for sudo??

I am looking for an alternative for sudo in linux, where i need not type the password. OR is there any other version of 'growisofs', which can be executed under sudo??? As currently 'growisofs' refuses to start under sudo... Thanks in advance (12 Replies)
Discussion started by: sony star
12 Replies

6. UNIX for Advanced & Expert Users

Alternatives for CLOCK_MONOTONIC

Hi, I need to develop timeout functionality in my code, which is not affected by system's time changes.Unfortunately I dont have CLOCK_MONOTONIC support in my OS. Are there any alternatives? (3 Replies)
Discussion started by: amitks21
3 Replies

7. UNIX for Dummies Questions & Answers

ASP alternatives

I have just found out that a project I have developed in ASP (ultradev) needs to be migrated to a unix server and won’t be able to support asp. Can anyone point me in the right direction to see what my options are with Unix? I have never worked with or developed for a Unix box before. Also,... (3 Replies)
Discussion started by: Ricki
3 Replies

Featured Tech Videos