It's possible you arrived because something blew up with nvidia. (I'm on cudatoolkit 11.4 and actually downgrading got me out of trouble - your mileage may vary.)

sudo apt install gcc-9 g++-9
sudo mkdir /usr/local/cuda/bin
sudo ln -s /usr/bin/gcc-9 /usr/local/cuda/bin/gcc

WARNING - I recommend using timeshift to make a backup of your working system. https://github.com/teejee2008/timeshift

This will get you the latest gcc 11

sudo add-apt-repository 'deb http://mirrors.kernel.org/ubuntu hirsute main universe'
sudo apt-get install g++-11
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 50
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 50
sudo update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-11 100
sudo update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-11 50
sudo update-alternatives --set g++ /usr/bin/g++-11
sudo update-alternatives --set gcc /usr/bin/gcc-11
sudo update-alternatives --set cpp-bin /usr/bin/cpp-11
gcc --version
gcc (Ubuntu 11-20210417-1ubuntu1) 11.0.1 20210417 

Copyright (C) 2021 Free Software Foundation, Inc.

Answer from johndpope on Stack Overflow
Top answer
1 of 2
2

It's possible you arrived because something blew up with nvidia. (I'm on cudatoolkit 11.4 and actually downgrading got me out of trouble - your mileage may vary.)

sudo apt install gcc-9 g++-9
sudo mkdir /usr/local/cuda/bin
sudo ln -s /usr/bin/gcc-9 /usr/local/cuda/bin/gcc

WARNING - I recommend using timeshift to make a backup of your working system. https://github.com/teejee2008/timeshift

This will get you the latest gcc 11

sudo add-apt-repository 'deb http://mirrors.kernel.org/ubuntu hirsute main universe'
sudo apt-get install g++-11
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 50
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 50
sudo update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-11 100
sudo update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-11 50
sudo update-alternatives --set g++ /usr/bin/g++-11
sudo update-alternatives --set gcc /usr/bin/gcc-11
sudo update-alternatives --set cpp-bin /usr/bin/cpp-11
gcc --version
gcc (Ubuntu 11-20210417-1ubuntu1) 11.0.1 20210417 

Copyright (C) 2021 Free Software Foundation, Inc.

2 of 2
0

From the looks of it, inside your conda environment, the gcc command has been linked to /home/ubuntu/anaconda3/envs/tensorflow_p36/bin/gcc, and the version is 4. Whereas outside the environment, the only gcc on the path is gcc-8, which corresponds to version 8.

Also, as you've observed, you are unable to create an alternative for gcc because it is linked to g++ alternative.

I also prefer to have gcc be the main alternative, and all other tools (including g++) follow suit. In this case, I will start by deleting the g++ alternative:

sudo update-alternatives --remove-all g++

Now that we've got that out of the way, we can create one for gcc which links to gcc-8

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-8 --slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-8 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-8

References

  1. https://askubuntu.com/a/26518/145907
  2. https://askubuntu.com/a/1206264/145907
🌐
Ask Ubuntu
askubuntu.com › questions › 1191132 › configure-gcc-8-to-be-default-gcc-error-no-alternatives-for-gcc
18.04 - Configure `gcc-8` to be default gcc "error: no alternatives for gcc" - Ask Ubuntu
November 23, 2019 - Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/x86_64-linux-gnu-g++-7 100 auto mode 1 /usr/bin/g++-4.8 60 manual mode 2 /usr/bin/g++-8 40 manual mode 3 /usr/bin/x86_64-linux-gnu-g++-7 100 manual mode Press <enter> to keep the current choice[*], or type selection number: 2 update-alternatives: using /usr/bin/g++-8 to provide /usr/bin/g++ (g++) in manual mode · So far so good, but when I test the g++ version, it's still the same! ... There are 2 choices for the alternative gcc (providing /usr/bin/gcc).
Discussions

raspbian - Problem with gcc/g++ versions - Raspberry Pi Stack Exchange
You can do that be running ln -s ... /usr/local/bin/gcc ... Thank you for your answer. I had seen that link but I was unaware of how exactly I would adapt those commands to work with the 8.1.0 version ... Sorry to bother you, just tried out the first command and got the following error update-alternatives: error: ... More on raspberrypi.stackexchange.com
🌐 raspberrypi.stackexchange.com
Problems after a recent update

Did you change your compiler version? Make sure you have the default popos version of gcc, same as was used to compile the kernel.

Run the driver install script from an unmodified environment, without thatever custom dev stuff you have added.

For me it says:

cc --versioncc (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0

Or maybe I DID upgrade mine and forgot :) Try: sudo apt install gcc-12

More on reddit.com
🌐 r/pop_os
21
7
September 3, 2023
[ERROR] | update-alternatives: error: alternative g++ can't be slave of gcc: it is a master alternative
➜ ~ cat /etc/os-release NAME="Ubuntu" ... ➜ ~ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60 --slave /usr/bin/g++ g++ /usr/bin/g++-10 [sudo] password for danny: update-alternatives: error: alternative g++ can't be slave of gcc: it is a master altern... More on github.com
🌐 github.com
0
May 8, 2025
unconfigured packages after ubuntu upgrade
Did you try sudo apt install -f ? More on reddit.com
🌐 r/Ubuntu
3
1
May 21, 2022
🌐
Digipen
azrael.digipen.edu › ~mmead › www › mg › update-compilers › index.html
Mead's Guide to Upgrading GCC and Clang on Linux
November 16, 2021 - But, they are in place so that when you decide to have multiple versions/programs for one command, you can do so easily. Let's look at gcc: ... update-alternatives: error: no alternatives for gcc This is telling us that there currently is no alternative for gcc.
Top answer
1 of 10
411

First erase the current update-alternatives setup for gcc and g++:

sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++

Install Packages

It seems that both gcc-4.3 and gcc-4.4 are installed after install build-essential. However, we can explicitly install the following packages:

sudo apt-get install gcc-4.3 gcc-4.4 g++-4.3 g++-4.4

Install Alternatives

Symbolic links cc and c++ are installed by default. We will install symbol links for gcc and g++, then link cc and c++ to gcc and g++ respectively. (Note that the 10, 20 and 30 options are the priorities for each alternative, where a bigger number is a higher priority.)

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 20

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.3 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 20

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc

sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++

Configure Alternatives

The last step is configuring the default commands for gcc, g++. It's easy to switch between 4.3 and 4.4 interactively:

sudo update-alternatives --config gcc
sudo update-alternatives --config g++

Or switch using script:

#!/bin/sh

if [ -z "$1" ]; then
    echo "usage: $0 version" 1>&2
    exit 1
fi

if [ ! -f "/usr/bin/gcc-1" ]; then
    echo "no such version gcc/g++ installed" 1>&2
    exit 1
fi

update-alternatives --set gcc "/usr/bin/gcc-$1"
update-alternatives --set g++ "/usr/bin/g++-$1"
2 of 10
62

execute in terminal :

gcc -v
g++ -v

Okay, so that part is fairly simple. The tricky part is that when you issue the command GCC it is actually a sybolic link to which ever version of GCC you are using. What this means is we can create a symbolic link from GCC to whichever version of GCC we want.

  • You can see the symbolic link :
ls -la /usr/bin | grep gcc-4.4
ls -la /usr/bin | grep g++-4.4
  • So what we need to do is remove the GCC symlink and the G++ symlink and then recreate them linked to GCC 4.3 and G++ 4.3:
rm /usr/bin/gcc
rm /usr/bin/g++

ln -s /usr/bin/gcc-4.3 /usr/bin/gcc
ln -s /usr/bin/g++-4.3 /usr/bin/g++
  • Now if we check the symbolic links again we will see GCC & G++ are now linked to GCC 4.3 and G++ 4.3:
ls -la /usr/bin/ | grep gcc
ls -la /usr/bin/ | grep g++
  • Finally we can check our GCC -v again and make sure we are using the correct version:
gcc -v
g++ -v
Top answer
1 of 1
3

In the main guide says

Now you have the needed compiler, but it is not yet set to be the default compiler. You can fix that using the instructions here.

If you read the link, it says that after you let your system know that there is an other gcc compiler version

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8.1.0 60 --slave /usr/bin/g++ g++ /usr/bin/g++-8.1.0

Then you can use the commands

sudo update-alternatives --config gcc
sudo update-alternatives --config g++

to select the default compilers


EDIT

Let me explain you a little what is going on so that you can understand your problem.

When you try to run a command like gcc --version your system searches the paths inside the environment PATH variable (windows has one too) to find that program. That variable has the path /usr/bin inside it, so it checks if there is a programmed called gcc on /usr/bin/gcc. You can see your path variable by running echo $PATH.

Since gcc comes in many versions, the /usr/bin/gcc file is not the actual binary, it is a symlink (something like the shortcuts on the Windows OS) that points to the actual binary (for example /usr/bin/gcc points to /usr/bin/gcc-6.3.0. You can create a symlink by running ln -sf /path/to/file /path/to/symlink (similar question here)

In your system the gcc-6.3.0 is installed as the default compiler. This means that the first gcc programmed found on the paths of PATH points to the gcc-6.3.0 binary.

Since you want when you call the gcc the gcc-8.1.0's binary to be called, what you have to do is make sure that the first gcc binary found on the paths of PATH is the gcc-8.1.0's binary.

In my raspberry pi the path variable is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin thus the /usr/local/bin folder will be checked every time before the /usr/bin (your's would be the same).

So what you will have to do is create a the /usr/local/bin/gcc symlink. You can do that be running ln -s /usr/local/gcc-8.1.0 /usr/local/bin/gcc

🌐
GitHub
gist.github.com › cobaohieu › ded429cb892b46ae9bfd9919a11e593a
update-alternatives for gcc on Ubuntu - Gist - GitHub
$ sudo apt update $ sudo apt-get upgrade -y $ sudo apt-get dist-upgrade -y $ sudo apt-get install build-essential software-properties-common manpages-dev -y $ sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y $ sudo apt-get update -y · Verify that the GCC compiler is successfully installed by running the following command that prints the GCC version: $ 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.
🌐
Tuxamito
tuxamito.com › wiki › index.php › Installing_newer_GCC_versions_in_Ubuntu
Installing newer GCC versions in Ubuntu - Tuxamito
March 6, 2018 - There are 3 choices for the alternative gcc (providing /usr/bin/gcc). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/gcc-5 90 auto mode 1 /usr/bin/gcc-5 90 manual mode 2 /usr/bin/gcc-6 80 manual mode 3 /usr/bin/gcc-7 70 manual mode Press <enter> to keep the current choice[*], or type selection number: 3 update-alternatives: using /usr/bin/gcc-7 to provide /usr/bin/gcc (gcc) in manual mode
Find elsewhere
🌐
Google Groups
groups.google.com › g › scintilla-interest › c › WtgbMh1D4DU
Changing default compiler on OpenSuSE
June 30, 2024 - Posting this here because now it matters. By default OpenSuSE appears to install gcc-7 and cpp-7. After you install version 11 of both via the package manager you still have a bit of work to do. roland@localhost:~> su - Password: localhost:~ # update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 50 update-alternatives: using /usr/bin/gcc-11 to provide /usr/bin/gcc (gcc) in auto mode localhost:~ # update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 20 localhost:~ # update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-11 50 update-alternatives: using /usr/bin/cpp-11 to provide /usr/bin/cpp (cpp) in auto mode localhost:~ # update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-7 20 localhost:~ # localhost:~ # update-alternatives --config gcc There are 2 choices for the alternative gcc (providing /usr/bin/gcc).
🌐
Ask Ubuntu
askubuntu.com › questions › 1515473 › problem-with-update-alternatives-and-cpp-after-updating-to-22-04
gcc - Problem with update-alternatives and cpp after updating to 22.04 - Ask Ubuntu
sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-11 1 · sudo apt upgrade now runs to completion with no errors. Thanks to a commenter for pointing out that cpp-11 is the default for Ubuntu 22.04. ... There are other ways to use the gcc,ccp,g++,... versions a CUDA install requires without changing the system defaults.
🌐
Ask Ubuntu
askubuntu.com › questions › 1472147 › gnu-compiler-below-the-required-version
gcc - GNU compiler below the required version - Ask Ubuntu
June 13, 2023 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 7 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 8 sudo update-alternatives --config gcc sudo update-alternatives --config g++
🌐
Reddit
reddit.com › r/pop_os › problems after a recent update
r/pop_os on Reddit: Problems after a recent update
September 3, 2023 -

I recently moved to my new place and wasn't on my laptop for about a week. I went to start up my laptop and run updates before gaming with my daughter. I noticed that there was an update for Nvidia-driver-535 available. I thought I already had it but it had the install button next to it. So I ran the normal OS updates, updates for some apps, and for the Nvidia driver.

After the update I ran my commands to:

watch -n 2 sensors

watch watch -n 2 nvidia-smi

Watch sensors worked normally but now I am getting an error for nvidia-smi. I tried to run Nvidia System Monitor Qt but that came back with a critical error as well. Both messages are in the screenshot below.

I tried several "solutions" online but it seems that none really worked. I tried removing all the drivers and reverting back to the old ones in Pop Shop, purging and re-installing 535 from Pop Shop, and purging and re-installing 535 from the Nvidia driver site.

I receive no errors from Pop Shop but if I try to install it from the .run file I get these errors:

Error "Building kernel modules" Error "Checking to see whether the nvidia kernel module was successfully built" ERROR: The nvidia kernel module was not created. Installation has Failed

Here is my first warning that the compiler check failed:

Later the errors start happening and keep on coming:

I am not sure what I need to look for to fix. Has anyone else had an issue like this before? Any advice would be appreciated. Thanks in advance.

🌐
GitHub
github.com › lynckia › licode › issues › 1957
[ERROR] | update-alternatives: error: alternative g++ can't be slave of gcc: it is a master alternative · Issue #1957 · lynckia/licode
May 8, 2025 - ➜ ~ cat /etc/os-release NAME="Ubuntu" ... ➜ ~ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60 --slave /usr/bin/g++ g++ /usr/bin/g++-10 [sudo] password for danny: update-alternatives: error: alternative g++ can't be slave of gcc: it is a master altern...
Author   lynckia
🌐
Linux Questions
linuxquestions.org › questions › linux-software-2 › problem-in-changing-gcc-version-4175603673
[SOLVED] problem in changing gcc version
April 12, 2017 - i am trying to change gcc version in my system my system specifications are: ubuntu 12.04 (32 bit) i search for this on google and find that version
🌐
GitHub
gist.github.com › yunqu › 0cc6347905f73b7448898f50484e77b3
Install a different version of GCC on Ubuntu · GitHub
The commands below will configure alternative for each version and associate a priority with it. The default version is the one with the highest priority, in our case that is gcc-9. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7
🌐
Reddit
reddit.com › r/ubuntu › unconfigured packages after ubuntu upgrade
r/Ubuntu on Reddit: unconfigured packages after ubuntu upgrade
May 21, 2022 -

After upgrading to version 22.04 (from 20.04) I get an error message whenever I try to install/update packages regarding a list of unconfigured packages. I tried issuing dkpg --configure -a, even removing and reinstalling these packages, but I can't resolve this problem.

I removed all installed versions of gcc, g++, cpp, and even build-essential, made sure that there are no errors, rebooted the system, but when I install build-essential I get the same error message.

The error message is:

Setting up cpp (4:11.2.0-1ubuntu1) ...
update-alternatives: error: alternative cpp can't be master: it is a slave of gcc
dpkg: error processing package cpp (--configure):
 installed cpp package post-installation script subprocess returned error exit s
tatus 2
dpkg: dependency problems prevent configuration of x11-xserver-utils:
 x11-xserver-utils depends on cpp; however:
  Package cpp is not configured yet.

dpkg: error processing package x11-xserver-utils (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of gcc:
 gcc depends on cpp (= 4:11.2.0-1ubuntu1); however:
  Package cpp is not configured yet.

dpkg: error processing package gcc (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of xorg:
 xorg depends on x11-xserver-utils; however:
  Package x11-xserver-utils is not configured yet.

dpkg: error processing package xorg (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of g++:
 g++ depends on cpp (= 4:11.2.0-1ubuntu1); however:
  Package cpp is not configured yet.
 g++ depends on gcc (= 4:11.2.0-1ubuntu1); however:No apport report written beca
use the error message indicates its a followup error from a previous failure.
                                                                             No 
apport report written because the error message indicates its a followup error f
rom a previous failure.
                       No apport report written because MaxReports is reached al
ready

  Package gcc is not configured yet.

dpkg: error processing package g++ (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of gdm3:
No apport report written because MaxReports is reached already
                                                               gdm3 depends on x
11-xserver-utils; however:
  Package x11-xserver-utils is not configured yet.

dpkg: error processing package gdm3 (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency p
roblems prevent configuration of build-essential:
 build-essential depends on gcc (>= 4:10.2); however:
  Package gcc is not configured yet.
 build-essential depends on g++ (>= 4:10.2); however:
  Package g++ is not configured yet.

dpkg: error processing package build-essential (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency p
roblems prevent configuration of ubuntu-desktop-minimal:
 ubuntu-desktop-minimal depends on gdm3; however:
  Package gdm3 is not configured yet.
 ubuntu-desktop-minimal depends on xorg; however:
  Package xorg is not configured yet.

dpkg: error processing package ubuntu-desktop-minimal (--configure):
 dependency problems - leaving unconfigured
🌐
Medium
xavier-jouvenot.medium.com › how-to-deal-with-several-gcc-version-on-your-machine-d251044aa9e8
How to deal with several gcc version on your machine | by Xavier Jouvenot | Medium
December 4, 2020 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10.1 1 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9.3 2sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10.1 1 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9.3 2
🌐
Reddit
reddit.com › r/pop_os › upgrade broke my system
r/pop_os on Reddit: Upgrade broke my system
March 14, 2023 -

im not tech savvy so please be patient with me:). So a sudo apt upgrade broke my system, specifically i could not use nvidia drivers anymore. Searching here and there I did sudo apt purge *nvidia* and tried installing the older nvidia driver again but same error happens as when I tried upgrading .

Errors were encountered while processing:  nvidia-dkms-470  nvidia-driver-470 E: Sub-process /usr/bin/dpkg returned an error code (1) 

So the make log file in /var/lib/dkms/nvidia/470.63.01/build/make.log showed:

warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0
  You are using:           cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0

gcc-12 is already installed, I dont know what i am doing wrong ? :(

Top answer
1 of 5
5
So it seems that gcc-11 was my default compiler despite gcc-12 already installed. I went ahead and installed g++-12. Then i changed the default compiler with update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 50 update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 50 update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-12 100 update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-12 50 update-alternatives --set g++ /usr/bin/g++-12 update-alternatives --set gcc /usr/bin/gcc-12 update-alternatives --set cpp-bin /usr/bin/cpp-12 And then installing nvidia drivers worked without errors ngl though its pretty stupid that linux systems still break till this day because of an upgrade No wonder people still use windows and macos pft
2 of 5
2
Run the following command to fix any broken dependencies, and complete any pending installation or removal process: sudo apt-get install -f If it doesn't work you can remove the partially installed packages using the command: sudo dpkg --remove --force-all nvidia-dkms-470 nvidia-driver-470 I recommend installing the Nvidia driver suggested by your system by running the following commands: sudo apt-get update sudo apt-get install nvidia-detect sudo nvidia-detect Install the driver using the following command: sudo apt-get install nvidia-driver-xxx You will have to reboot your device, then use the command: nvidia-smi This will display information about your current driver and the GPU. If it gives an error the GPU is either not detected or the driver wasn't installed properly. Hope it helps!
🌐
jdhao's digital space
jdhao.github.io › 2020 › 07 › 02 › ubuntu_update_alternatives
Switch Command with update-alternatives on Ubuntu · jdhao's digital space
October 28, 2021 - If we want the command gcc to point to /usr/bin/gcc-4.8, we often want g++ to point to /usr/bin/g++-4.8. Using symlinks to manage version switch is not convenient in this case, since we need to create two or more symlinks. If we want to switch back to GCC 7.4, we then need to remove the old symlinks and create new ones, which is cumbersome. update-alternatives provides what is called master and slave alternatives, where if you change the master symlink, the slave symlinks will also get changed automatically.