To downgrade gcc in Debian Linux, you can follow these steps:
- First, check the available gcc versions in the Debian repositories using the following command:
apt-cache search gcc
- Identify the version number of the gcc package that you want to install.
- Install the desired older version using the apt-get command and specifying the version number. For example, to install gcc-7, use the following command:
sudo apt-get install gcc-7
- After the installation is complete, you need to update the alternatives for gcc and g++ to the older version. Use the update-alternatives command as follows:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7
- Confirm the installation and set the older version as the default gcc by running the update-alternatives command with the --config option:
sudo update-alternatives --config gcc
- You will see a list of available gcc versions. Select the number corresponding to the desired version and press Enter.
- To check the gcc version, use the following command:
Now you have successfully downgraded gcc to the desired version in Debian Linux.