Fedora/CentOS does not use alternatives to select the compiler. It is true that Fedora/CentOS has and uses the alternatives package. However alternatives does not automatically manage every installed software application, and each software package has to be explicitly set up to use alternatives, and in Fedora/CentOS this is simply not done for gcc.

Building gcc is no small feat. By comparison, using an explicit path to your custom gcc build seems like an insignificant triviality. Or, put your custom built gcc's location in your PATH environment variable first, and move on to something else.

Answer from Sam Varshavchik on Stack Overflow
🌐
Linux Man Pages
man7.org › linux › man-pages › man1 › update-alternatives.1.html
update-alternatives(1) - Linux manual page
This is done so that the system ... is a Good Thing. When each package providing a file with a particular functionality is installed, changed or removed, update-alternatives is called to update information about that file in the alternatives system....
🌐
Baeldung
baeldung.com › home › administration › the update-alternatives command in linux
The update-alternatives Command in Linux | Baeldung on Linux
July 24, 2024 - So, let’s select vim as editor and check editor‘s manual: $ sudo update-alternatives --set editor /usr/bin/vim.tiny update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/editor (editor) in manual mode
Top answer
1 of 2
9

I would try cleaning it up manually. I've never done this so make sure you backup beforehand.

  • Remove the link from /etc/alternatives
  • Remove the relevant file from the admin directory
    • /var/lib/dpkg/alternatives/ on ubuntu (debian may be the same but check the man pages under the FILES section)
    • /var/lib/alternatives/ on CentOS 6&7
2 of 2
11

Removing them manually resulted in ... is already managed by ... error in my case. Aside from that, the manual removal also didn't scale, as i've had added multiple multiple alternatives for the centralized symlink. It's just a mess.
When it comes to either update-alternatives or alternatives, they both provide the --remove and --remove-all flags. As for the former flag, it only removes one single alternative of the link group. For example

$ update-alternatives --list python3
/usr/bin/python3.8
/usr/bin/python3.9

$ sudo update-alternatives --remove python3 /usr/bin/python3.9

$ update-alternatives --list python3
/usr/bin/python3.8

The form of the --remove flag goes by update-alternatives --remove symlink-generic-name /path/to/one/executable/alternative

However, if you want to outright erase the generic name with all of its associated alternatives all at once, then --remove-all is the way to go.

$ update-alternatives --list python3
/usr/bin/python3.8
/usr/bin/python3.9

$ sudo update-alternatives --remove-all python3

$ update-alternatives --list python3
update-alternatives: error: no alternatives for python3

$ update-alternatives --query python3
update-alternatives: error: no alternatives for python3
🌐
Linux Man Pages
linux.die.net › man › 8 › update-alternatives
update-alternatives(8) - Linux man page
A directory, by default /var/lib/alternatives, containing alternatives' state information. ... A set of related symlinks, intended to be updated as a group.
🌐
Alibaba Cloud
topic.alibabacloud.com › a › centoslinux-alternatives-and-update-alternatives-and-software-version-switching_2_61_30154973.html
Centos/linux alternatives and update-alternatives and software version switching
Usage: Alternatives--install < ... option is to add a new set of system command links, using the following syntax: Update-alternatives--install Link name path priority [--slave link name path] ......
Top answer
1 of 2
9

Basically it says to your machine to use this alternative of Jave JDK instead of the default one, which, in Linux systems, is OpenJDK.

A brief extract from the man page is better than any answer I could write:

update-alternatives creates, removes, maintains and displays information about the symbolic links comprising the Debian alternatives system.

It is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time. For example, many systems have several text editors installed at once. This gives choice to the users of a system, allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice for an editor to invoke if the user has not specified a particular preference.

Debian's alternatives system aims to solve this problem. A generic name in the filesystem is shared by all files providing interchangeable functionality. The alternatives system and the system administrator together determine which actual file is referenced by this generic name. For example, if the text editors ed(1) and nvi(1) are both installed on the system, the alternatives system will cause the generic name /usr/bin/editor to refer to /usr/bin/nvi by default. The system administrator can override this and cause it to refer to /usr/bin/ed instead, and the alternatives system will not alter this setting until explicitly requested to do so.

With --install you specified a link, "/usr/bin/java" a name "java" and a path "/usr/lib/java/JDK...." and you add a group of alternatives to the system. link is the generic name for the master link, name is the name of its symlink in the alternatives directory, and path is the alternative being introduced for the master link.

I hope to be clear enough, Here there is a post regarding java alternatives.

For the complete usage list I suggest to look at the same manual page, typing man update-alternatives on your OS shell;

2 of 2
0

i want to explain it for you from scratch ... if you have 2 or more versions of a program that starts with a same command in linux you can use update-alternatives command for determining the default version of that program and you can also change the default version of that command easily .. assume that you have 2 version of python on your system. python 2 & python 3. by default python command on linux starts the python2 interpreter on the shell . you think that python 2 is old and you want to use python 3 instead of python2 . one of the solution is that you enter python3 command on the shell and start the python interpreter that its version is more than 3 ... but you want to enter python command and shell recognize that you want to run python3 interpreter . here,update-alternatives command do it's work and determine the default version and versions of a program you want to use for a specific command .

i told you that python command start python 2 interpreter by default . you want to change it . follow the example :

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1.

when you execute this command on linux you are telling to shell that after this time two links of two different programs are linked to python command on linux .. infact you install the python3 program on python command on linux and two programs exist at 1 command that you can change the defaults of these programs and run what of these programs you want by changing priority in command or configure it manually to set the default program ..

hope this is useful for you !

🌐
Red Hat
redhat.com › en › blog › alternatives-command
Introduction to the alternatives command in Linux
November 20, 2025 - Originally, this was a convenience utility, written in Perl, from the Debian Linux project, called update-alternatives. Red Hat rewrote the command without Perl, and it's been propagated throughout Fedora-based distributions such as Red Hat ...
Find elsewhere
🌐
TecAdmin
tecadmin.net › linux-update-alternatives-command
Update-alternatives Command: A Comprehensive Guide for Linux Users – TecAdmin
April 26, 2025 - By the end of this tutorial, you ... The update-alternatives command in Linux is used to create, remove, maintain, and display information about the symbolic links that determine default commands for various software alternatives....
🌐
CommandLinux
commandlinux.com › home › man page › update-alternatives
Update-alternatives
May 13, 2026 - When each package providing a file with a particular functionality is installed, changed or removed, update-alternatives is called to update information about that file in the alternatives system.
🌐
Linux Hint
linuxhint.com › update_alternatives_ubuntu
How to Use update-alternatives Command on Ubuntu – Linux Hint
If you have 2 or more versions of the same command, you can use update-alternatives to set which one to use by default and also switch between them very easily. For example, let’s say, you have Python 2 and Python 3 installed on your computer.
🌐
SUSE
documentation.suse.com › fr-fr › sles › 15-SP6 › html › SLES-all › cha-update-alternative.html
update-alternatives: managing multiple versions of commands and files | Administration Guide | SLES 15 SP6
March 30, 2026 - For example, if Java 1.7 and Java 1.8 are both installed on the system, the alternatives system script (update-alternatives) is called from inside the RPM package. By default, the alternatives system will refer to version 1.8: higher versions also have a higher priority.
🌐
SUSE
documentation.suse.com › sles › 15-SP1 › html › SLES-all › cha-update-alternative.html
SUSE - Open Source Solutions for Enterprise Servers & Cloud
July 18, 2022 - SUSE Linux Enterprise Server, based on latest SUSE Linux Enterprise, is another example of our open approach helping you optimize and modernize your multimodal IT infrastructure. Original documentation as ZIP archive: Download archive ... Find the latest updates, including new features, enhancements, bug fixes, and important information about deprecated or removed packages.
🌐
IONOS
ionos.com › digital guide › server › know-how › centos alternatives
What are the top 3 CentOS alternatives? RHEL, Rocky Linux, AlmaLinux - IONOS
January 20, 2025 - After Red Hat announced the end of CentOS, CloudLin­ux developed a CentOS al­ter­na­tive, which first saw a stable release in 2021. AlmaLinux is now main­tained by the non-profit AlmaLinux OS Foun­da­tion. Open Source: Just like CentOS, AlmaLinux is also free and open source. A dedicated community con­tin­u­ous­ly develops the dis­tri­b­u­tion and offers all packages and updates at no cost.
🌐
guvi.in
studytonight.com › linux-guide › update-alternatives-command-in-linux
update-alternatives Command in Linux
February 13, 2023 - The symbolic links that make up the package alternatives system are created, removed, maintained, and shown using the update-alternatives command. Multiple programmes that perform the same or related functions may be installed simultaneously on a single system.