
To ivanmara555's comment using the ppa repository.Īs of today May 25th 2020 on Ubuntu 20.04 your list of commands does not install the latest 10.1.0.

Sudo update-alternatives -install /usr/bin/gcc gcc /usr/bin/gcc-10 60 -slave /usr/bin/g++ g++ /usr/bin/g++-10 & Sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y & Sudo apt-get install build-essential software-properties-common -y & If everything went fine you should see gcc 6.1.1 by the time I am writing this gist When completed, you must change to the gcc you want to work with by default. Sudo update-alternatives -install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 -slave /usr/bin/g++ g++ /usr/bin/g++-4.8 Sudo update-alternatives -install /usr/bin/gcc gcc /usr/bin/gcc-6 60 -slave /usr/bin/g++ g++ /usr/bin/g++-6 & \ Sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y & \ Sudo apt-get install build-essential software-properties-common -y & \

If you are still reading let's carry on with the code. To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below. These commands are based on a askubuntu answer
