The update-alternatives Linux command can be used to update the default version of GCC.
Example: Use GCC 7
sudo update-alternatives --set gcc /usr/bin/gcc-7
Example: Use GCC 8
sudo update-alternatives --set gcc /usr/bin/gcc-8
Example: Use GCC 9
sudo update-alternatives --set gcc /usr/bin/gcc-9
Example: Use GCC 10
sudo update-alternatives --set gcc /usr/bin/gcc-10
Example: Use GCC 11
sudo update-alternatives --set gcc /usr/bin/gcc-11
If you want to set GCC version forever, please use the following command to update your .profile
file:
echo "sudo update-alternatives --set gcc /usr/bin/gcc-11" >> ~/.profile
Please, let us know if some essentials are missing. Join our Discord Community to discuss new ideas and features.