Multiple GCC installation

#
# Commands are tested on Ubuntu 14.04
#
# Issue following command to verify which GCC version is installed
gcc –version
— OR —
g++ –version
gcc (Ubuntu 4.8.5-4ubuntu8~14.04.2) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# Install the GCC-7
sudo apt-get update -y && \
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
sudo apt-get update -y && \
sudo apt-get install gcc-7 g++-7 -y
# Let's manage two versions
sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10 –slave /usr/bin/g++ g++ /usr/bin/g++-4.8
sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-7 20 –slave /usr/bin/g++ g++ /usr/bin/g++-7
# Machine is configured for GCC-7 at this point, let's see
gcc –version
— OR —
g++ –version
gcc (Ubuntu 7.3.0-21ubuntu1~14.04) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# To switch b/w different versions
sudo update-alternatives –config gcc
# To see available versions
sudo update-alternatives –list gcc
# To remove link
sudo update-alternatives –remove gcc /usr/bin/gcc-7