Nvidia Drivers in Ubuntu

Check the driver which is being used for Nvidia card with the following command.

sudo lshw -c display

You can also use video instead of display.

sudo lshw -c video

By default, the open source nouveau driver is being used for Nvidia card.

Run the following command to list available driver for your Nvidia card from the default Ubuntu repository.

sudo ubuntu-drivers devices

install the recommended driver, run the following command.

sudo ubuntu-drivers autoinstall

If you want to install a particular driver, run the following command.

sudo apt install nvidia-driver-version-number

For example:

sudo apt install nvidia-driver-340

After the driver is installed, Reboot the computer to enable nvidia-prime, which is technology to switch between Intel and Nvidia graphics card.

sudo shutdown -r now

Now the proprietary Nvidia driver is being used.

sudo lshw -c display

Removing Nvidia Drivers

Search what packages from nvidia you have installed.

dpkg -l | grep -i nvidia

Nvidia-common package has a dependency on ubunut-desktop.

To purge everything related to nvidia you can give this command

sudo apt-get remove --purge nvidia-*

Above command will also remove the nvidia-common package and the nvidia-common package has as a dependency the ubuntu-desktop package.

So after above command you should also give the installation command for ubuntu-desktop package

sudo apt-get install ubuntu-desktop

Also sometimes the nouveau driver get blacklisted from nvidia driver. With purge command it should UN-blacklisted. If you want to be sure that nouveau will be load in boot, you can force-load it by add it to /etc/modules

echo 'nouveau' | sudo tee -a /etc/modules

Last , search for the xorg.conf file and remove it as well

sudo rm /etc/X11/xorg.conf

In summary

sudo apt-get remove --purge nvidia-*
sudo apt-get install ubuntu-desktop
sudo rm /etc/X11/xorg.conf
echo 'nouveau' | sudo tee -a /etc/modules

LightDm install directory missing

t is possible that the folder /var/lib/lightdm has not been created.

You could try: mkdir -p /var/lib/lightdm; chown -R lightdm:lightdm /var/lib/lightdm ; chmod 0750 /var/lib/lightdm with root permission if needed.

Reference:
https://www.linuxbabe.com/ubuntu/install-nvidia-driver-ubuntu-18-04
https://askubuntu.com/questions/692577/ubuntu-15-10-boot-hangs-when-starting-lightdm
https://askubuntu.com/questions/206283/how-can-i-uninstall-a-nvidia-driver-completely

Install/Uninstall packages in Ubuntu from tar.gz

Unzip the tar.gz by using the compression/decompression program in your system.

The steps to make and build:

./configure 
make
make install
//Remove package
Make unistall

To remove the package make install is used. Sometimes if the unistall step is not mentioned in the make file, the removal of the installed package would get difficult and can even lead to a broken system.

To prevent this, instead of installing the package using make install, we can use the checkinstall utility available in the ubuntu repo. It cretaed a .deb package for the program. This .deb package can be easily removed using any package manager like apt, synaptic, dpkg, aptitude.

sudo apt install checkinstall
sudo checkinstall

 

Example to remove package after installing it through checkinstall.



**********************************************************************

 Done. The new package has been installed and saved to

 /home/ajinkyawavare/Downloads/scid_vs_pc-4.19/scid-vs-pc_4.19-1_amd64.deb

 You can remove it from your system anytime using: 

      dpkg -r scid-vs-pc

**********************************************************************