Removing and Installing Nvidia Drivers on Linux
*Ubuntu based
Uninstalling previously installed Nvidia drivers
sudo apt-get remove --purge '^nvidia-.*'
sudo apt autoremove
sudo apt install ubuntu-drivers-common -y
reboot
sudo: Runs the command with superuser privileges.
'^nvidia-.*' : Anything Nvidia related.
ubuntu-drivers-common: This is a meta-package that provides common tools and utilities for managing drivers in Ubuntu, particularly for graphics cards (like NVIDIA or AMD).
-y: A flag that automatically confirms the installation prompt without requiring user input. It stands for "yes," so it skips the confirmation step.
Add the repository
sudo add-apt-repository ppa:graphics-drivers/ppa
add-apt-repository: A tool used in Ubuntu systems to manage and add new software repositories or PPAs.
ppa:graphics-drivers/ppa: PPA to be added, which is maintained by the graphics-drivers team for providing updated NVIDIA drivers.
List available drivers
ubuntu-drivers devicves

(Manual) Pick a driver version and install
sudo apt install nvidia-driver-590-open
(Alternate) auto install the recommended one
sudo ubuntu-drivers autoinstall
Reboot
reboot
either use reboot command or restart your computer (system)