# Ubuntu – How to add slave to existing update-alternatives link group

aptgccupdate-alternatives

Then I realised that while this slaved the g++ version to the gcc version, I had forgotten to add a slaving for the gcov version. How can I add gcov as a slave to this link group?

I checked the man for update-alternatives but I didn't see a way without just going from scratch again. If this case is the way to do it then do I need to remove the current update-alternative group to start fresh?

(I am on Bash on Ubuntu on Windows, so 16.04)

I googled this issue, and in the first three pages, there are only two relevant results. One is this no-answer problem; another is a bug report on CentOS bug tracker, update-alternatives replaces new slave links instead of adding ones.

If the alternative name specified exists already in the alternatives system's records, the information supplied will be added as a new set of alternatives for the group.

But for the time being, I'm afraid that we can achieve this only by adding all slaves to existing link group at one time, including both original and newly added slaves.

To me, configuring java alternatives, it's

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk-10/bin/java" 10 \
--slave "/usr/bin/jar"          "jar"           "/opt/jdk-10/bin/jar" \
--slave "/usr/bin/jarsigner"    "jarsigner"     "/opt/jdk-10/bin/jarsigner" \
--slave "/usr/bin/javac"        "javac"         "/opt/jdk-10/bin/javac" \

You don't need to remove the link group first, as the current behavior is the newly added slaves completely replace original ones. Be aware that you can always use update-alternatives --display "\$your_command" to view alternative status safely.