How to install nvidia drivers on ubuntu

First update your new system

sudo apt-get update
sudo apt-get dist-upgrade

ensure what graphics driver your system needs.

ubuntu-drivers devices

install intel driver first

sudo apt-get install intel-microcode
sudo apt-get install nvidia-xxx

That's all.

Note: nvidia-xxx

you must enter the recommended driver version displayed in ubuntu-drivers devices and I must warn you. Updating the kernel may cause you problems, so once you installed that NVIDIA driver, please don't upgrade with this commands (sudo apt dist-upgrade or sudo apt upgrade and sudo apt-get dist-upgrade), please use sudo apt-get upgrade that command will hold new kernel releases.