Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Understanding the Command: update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60

Tech May 9 5

The update-alternatives utility is a standard tool in Debian-based Linux distributions (like Ubuntu) that manages multiple versions of programs providing the same functionality. It uses symbolic links and priority values to determine which version should be used by default when a command is invoked.

Consider the following command:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60

This registers GCC version 13 as an available opsion for the gcc command. Below is a breakdown of each component:

--install

This subcommand adds a new alternative to the system. It requires four arguments: the link path, the group name, the actual binary path, and a priority value.

/usr/bin/gcc

This is the primary symlink that users interact with when running gcc. The update-alternatives system controls what this symlink points to based on configured alternatives and their priorities.

gcc

This is the name of the alternatives group. All registered versions of the GCC compiler are grouped under this identifier, allowinng them to be managed collectively.

/usr/bin/gcc-13

This specifies the full path to the actual executable—in this case, the GCC 13 compiler binary. This version will be linked to /usr/bin/gcc if selected by the alternatives system.

60

This integer represents the priority of this alternative. When multiple versions exist, the one with the highest priority is automatically selected as the default. For instance, if GCC 10 has priority 40 and GCC 13 has priority 60, the latter becomes the default.

After running the command, the system recognizes /usr/bin/gcc-13 as a valid candidate for the gcc command. If no other alternative has a higher priority, the symlink /usr/bin/gcc will point to /usr/bin/gcc-13.

To manually switch between installed versions, use:

sudo update-alternatives --config gcc

This presents an interactive menu listing all registered GCC versions, allowing you to select your preferred default.

Related Articles

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

SBUS Signal Analysis and Communication Implementation Using STM32 with Fus Remote Controller

Overview In a recent project, I utilized the SBUS protocol with the Fus remote controller to control a vehicle's basic operations, including movement, lights, and mode switching. This article is aimed...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.