I have installed gcc-7 and g++-7 using the answer at https://askubuntu.com/a/581497/333103.

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)

1 Answer 1


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.

In --install section of the Debian update-alternatives manpages, it's said that

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" \
    --slave "/usr/bin/javadoc"      "javadoc"       "/opt/jdk-10/bin/javadoc" \
    --slave "/usr/bin/javap"        "javap"         "/opt/jdk-10/bin/javap" \
    --slave "/usr/bin/javaws"       "javaws"        "/opt/jdk-10/bin/javaws"

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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .