Cleaning Up A Broken NVidia Installation
remove the current nvidia driver running
sudo apt purge nvidia-* && sudo apt autoremove
note the version of the nvidia driver you're removing, say nvidia-xyz
blacklist nouveau by opening /etc/modprobe.d/blacklist-nouveau.conf with your favourite editor and inserting
blacklist nouveau blacklist lbm-nouveau options nouveau modeset=0 alias nouveau off alias lbm-nouveau off
Disabling the kernel nouveau (not sure whether this is necessary, though, but it does not seem to do harm to the installation)
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf sudo update-initramfs -u
Reboot the computer and login to a terminal without display manager, e.g., CTRL+ALT+F1. Unfortunately, the display manager has been started already (still available under CTRL+ALT+F7), thus the service need to be stopped
sudo service lightdm stop
Activating gdm (gdm3) as default display manager.
sudo dpkg-reconfigure gdm3
This will return an error saying that the service has not been started and hence the display manager could not be switched. No worries, the switch will be carried out upon reboot.
Re-installing the nvidia driver that has been removed earlier, where xyz is the version that was uninstalled under the first step.
sudo apt install nvidia-xyz
Reboot your system
sudo shutdown -r now