Switch between different versions of a program in Linux

Pingu

Surely, and if you don't already know, you know that in Linux can install several versions of the same program or command at the same time, that is, we can count on the same system an app A whose version is xz and that same app A in its version xw, etc. This is not possible in other OS, since it would generate conflicts and during the installation it would ask us to uninstall the previous version or update. But in the Unix world it is sometimes interesting to have older versions of a program, even if we have a more modern version for certain reasons.

Among the programs that we may need with different versions we find Java, PHP, Python, compilers like gcc or g ++, and a long etc. The needs or reasons why we have to use several versions can be very varied, for example, in the case of Python, it is frequent that we can be writing or using .py scripts that require the use of different versions of Python and for for this we will have the need to have the different versions installed in the system.

Well, with that said, I am going to describe how we can switch from one version to another. And for this there are several alternatives, I have even seen some graphs or pull aliases to link with the different versions of a command, but I am going to describe it using other methods to the console. First I recommend you uninstall all versions of said software and do a fresh installation using a line with the package manager. For example, imagine that you are going to install gcc in several versions:

[sorucecode language = »plain»]

sudo update-alternatives --remove-all gcc

SUDO APT-GET INSTALL GCC-4.4 GCC-8.2

[/ sourcecode]

With this we will already have our two versions of GNU GCC installed correctly. Now, if you use the gcc command you will see that one of the versions is the one that has been imposed by default, so if you don't specify that will be the one you are using:

gcc --version

Well if we want use the other version, we just have to do the following:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8.2 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 20
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --config gc</pre>

And with it you can toggle interactively between both versions ...


Be the first to comment

Leave a Comment

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

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.