Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?

How to manage versions using update-alternatives



Background

Lately I wanted to run the tip to finish assessments within the older chrome browser because the instrument the chrome driver accessible to me was solely working with the older model of chrome.
The answer as a substitute of downgrading my chrome set up was to put in a number of variations of chrome-browser. Extra on this in my latest article how and the place to become older variations of google-chrome.
Lengthy story quick, a number of the command-line instruments require or count on to be be capable of work together with system model and wish to have the ability to change it rapidly and effortlessly and at greatest in command-line interface.
The identical goes when putting in a number of variations of java, node, pyhton and so forth. In java world folks may be utilizing sdkman [www.sdkman.org] or node js world us used nvm www.getnvm.org.



What’s update-alternatives

update-alternatives is instrument supplied Debian primarily based distributions which is designed to assist to handle a number of variations or cases of the one command/program
Debian Alternatives. Replace-alternatives in Debian primarily based system like Ubuntu is used as default choice by apt, nevertheless, it gives the command-line interface to work together with the settings and so as to add and take away entries manually.

It may possibly additionally present performance to replace one thing what known as slave hyperlinks.
That is e.g. helpful when you have got a model particular man web page alongside the software program model you wish to add to your system.
It would inform update-alternatives to replace additionally all related hyperlinks when you find yourself altering the present model. The analogy within the nodejs world can be corresponding npm set up or in python world it might be corresponding pip. We additionally wish to change these if we alter the present model of python or node.



Find out how to set up one other model with update-alternatives

in the event you plan to make use of update-alternavives to e.g. set up the a number of node variations you’ll obtain the specified model and unpack it within the listing of the selection
In my case it might be /choose/google/chromium/1027016/chrome-linux/

it will include binary /choose/google/chromium/1027016/chrome-linux/chrome

if you have already got chrome already put in and you probably did that from the Debian bundle by

sudo apt set up google-chrome-stable.deb
Enter fullscreen mode

Exit fullscreen mode

your have already got used update-alternatives and operating

update-alternatives --display google-chrome
Enter fullscreen mode

Exit fullscreen mode

will present output:

google-chrome - auto mode
hyperlink greatest model is /usr/bin/google-chrome-stable
hyperlink at present factors to /usr/bin/google-chrome-stable
hyperlink google-chrome is /usr/bin/google-chrome
/usr/bin/google-chrome-stable - precedence 200
Enter fullscreen mode

Exit fullscreen mode

signifies there is just one model of google-chrome and it exhibits the situation and precedence for auto mode (the upper model takes priority)
I do not wish to go into an excessive amount of element right here because it might be present in man pages or on-line debian alternatives
additionally operating does related, record the present hyperlinks

update-alternatives --list google-chrome

?> /usr/bin/google-chrome-stable
Enter fullscreen mode

Exit fullscreen mode

Investigating hyperlinks additional we get to:

/usr/bin/google-chrome --> /and so forth/options/google-chrome
/and so forth/options/google-chrome --> /usr/bin/google-chrome-stable
/usr/bin/google-chrome-stable --> /choose/google/chrome/google-chrome
Enter fullscreen mode

Exit fullscreen mode

The final one is tough hyperlink to executable file

now you can add the downloaded particular model to it by executing the next

sudo update-alternatives --install /usr/bin/google-chrome google-chrome /choose/google/chromium/1027016/chrome-linux/chrome
Enter fullscreen mode

Exit fullscreen mode

if you wish to use this as default hyperlink you’ll be able to add the precedence quantity on the finish, larger than present 200, however in the event you do not you should utilize the next to vary the model system large.

sudo update-alternatives --config google-chrome
Enter fullscreen mode

Exit fullscreen mode

output (relying on given precedence nubmer this may differ):

There are 2 decisions for the choice google-chrome (offering /usr/bin/google-chrome).

Choice    Path                                              Precedence   Standing
------------------------------------------------------------
  0            /choose/google/chromium/1027016/chrome-linux/chrome   300       auto mode
  1            /choose/google/chromium/1027016/chrome-linux/chrome   300       handbook mode
* 2            /usr/bin/google-chrome-stable                      200       handbook mode

Press <enter> to maintain the present alternative[*], or sort choice quantity:
Enter fullscreen mode

Exit fullscreen mode

in the event you select one choice the hyperlink will now not be in auto mode, however you’ll be able to return anytime to automode by operating

sudo update-alternative --auto google-chrome
Enter fullscreen mode

Exit fullscreen mode



slave hyperlinks

As talked about earlier than, these are related hyperlinks which ought to change when grasp hyperlink adjustments. The examples are node and npm or python and pip. It additionally works with handbook pages as some packages set up additionally handbook pages. That is additionally the case when putting in google-chrome as deb bundle as above.
Model managers not primarily based on update-alternatives normally add/edit the entry in manpath pointing to appropriate man web page.
update-alternatives does this by way of talked about slave hyperlinks.

In case of google-chrome, although it makes use of update-alternatives by default, it doesn’t use slave hyperlinks and the installer merely copies the person web page within the man location. Which prevents update-alternatives to use sim hyperlink right here. It may possibly’t delete the unique file and exchange it with hyperlink as it might level wherever. Its may be discovered operating

man -w google-chrome
Enter fullscreen mode

Exit fullscreen mode

We might manually transfer man entry for google-chrome-stable elsewhere and let update-alternatives make the most of slave hyperlinks, however we might additionally add one other man entry by way of slave hyperlink to show flexibility. Let’s do it.

man web page for chromium is cosmetically totally different to man web page for google-chrome. If we wish to additionally change the person web page when swapping the browser model we are able to do it by

sudo update-alternatives --install /usr/bin/google-chrome google-chrome /choose/google/chromium/chrome-linux/chrome 
--slave /usr/share/man/man1/chromium.1.gz chromium.1.gz /choose/google/chromium/chromium.1.gz
Enter fullscreen mode

Exit fullscreen mode

The results of this will probably be following. If we use the google-chrome-stable the handbook entry for chromium by way of man chromium is not going to be accessible, however swapping the model for chromium will make the handbook entry for chromium accessible alongside the unique handbook entry which is/was set as exhausting hyperlink (precise file).



Abstract

This quick articles show the essential capabilities of the instrument update-alternatives. Extra element may be discovered on handbook pages or on Debian web site.



Hyperlinks

Add a Comment

Your email address will not be published. Required fields are marked *

Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?