在 Ubuntu 下“卸载 gcc”要分几种情况,下面按常见需求说明:
gcc --version
dpkg -l | grep gcc
sudo apt remove gcc
sudo apt purge gcc
sudo apt autoremove
ls /usr/bin/gcc*
sudo apt remove gcc-9
sudo apt purge gcc-9
如果你用 update-alternatives 管理 gcc:
sudo update-alternatives --list gcc
sudo update-alternatives --remove gcc /usr/bin/gcc-9
⚠️ 不要随意卸载系统默认 gcc
Ubuntu 很多系统组件和内核模块依赖 gcc,强行卸载可能导致:
✅ 建议做法:
gcc-x 指定版本sudo apt purge gcc-11
sudo apt autoremove
如果你能告诉我:
我可以给你更精确的命令。