为什么我不能在 Linux 上使用 gcc-9.3.0?

Why can't I use gcc-9.3.0 on Linux?

我用apt安装了gcc-9.3.0,但是只能用sudo like

sudo gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 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.

gcc --version
gcc (OpenFOAM) 6.3.0
Copyright (C) 2016 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.

我想在没有 sudo 的情况下使用它。 有什么不同? 如何从我的普通用户帐户使用 gcc-9.3.0?

GCC 不需要特殊的 sudo 权限 - 您看到的区别是因为您安装了 2 个版本,但是第 6 版出现在第 9 版之前 PATH

要修复它,请将 GCC 9 的安装目录添加到 PATH 的前面。