Fundamentals 4 min read

Mastering Linux Alternatives: Switch and Manage Multiple Software Versions Easily

This guide explains how to use the Linux alternatives system to install, configure, add, view, switch, and remove multiple versions of software, providing step‑by‑step commands and examples for both Debian‑based and RPM‑based distributions.

Ops Development & AI Practice
Ops Development & AI Practice
Ops Development & AI Practice
Mastering Linux Alternatives: Switch and Manage Multiple Software Versions Easily

Basic Concept

The alternatives command is a shorthand for update-alternatives. It manages symbolic links (e.g., in /usr/bin) that point to the user‑selected default program version. It is available on Debian‑derived distributions and many other Linux families.

Installation

On Debian‑based systems ensure the package is installed:

sudo apt-get update
sudo apt-get install alternatives

On RPM‑based distributions (Red Hat, Fedora, CentOS) the tool is provided by the chkconfig package and is installed by default.

Adding a New Program Version

Register a new alternative by specifying the generic link, the name, the target binary, and a priority. Example for Python interpreters:

sudo alternatives --install /usr/bin/python python /usr/bin/python3.8 100
sudo alternatives --install /usr/bin/python python /usr/bin/python3.9 200

In this example /usr/bin/python is the generic path, python is the alternative name, the two target binaries are the actual executables, and the numeric values are priorities (higher = preferred).

Viewing and Selecting Versions

List all alternatives for a name: sudo alternatives --display python Switch the default interactively: sudo alternatives --config python The command prints each registered version with its priority and a selection number.

Automatic vs Manual Mode

In automatic mode the system selects the highest‑priority alternative. In manual mode the user‑chosen version is kept even if a higher priority is added. Change the mode with:

sudo alternatives --auto python   # automatic
sudo alternatives --manual python # manual (if supported)

Removing an Alternative

To delete a specific target from the alternative set:

sudo alternatives --remove python /usr/bin/python3.8

Summary

Using alternatives allows precise control over multiple versions of a program, simplifying maintenance and ensuring the intended binary is invoked.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxcommand-lineSystem Administrationalternativessoftware versioning
Ops Development & AI Practice
Written by

Ops Development & AI Practice

DevSecOps engineer sharing experiences and insights on AI, Web3, and Claude code development. Aims to help solve technical challenges, improve development efficiency, and grow through community interaction. Feel free to comment and discuss.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.