Latest NVidia drivers

drivers from Ubuntu

First install nvidia-current. This will download the source of the driver and compile it.

Reboot.

Then run the command

nvidia-xconfig

as root and restart X. That's it.

The nvidia-xconfig command has many options. Use option -A (advanced help) to print all of them.

drivers direct from NVidia

You can get more recent drivers if you download them direct from the NVidia site. This is the preferred way if you are not running an Ubuntu kernel, but rather built a vanilla Linux kernel yourself. The NVidia site has also got beta drivers. Installing the latest drivers from www.nvidia.com is just a matter of running the downloaded .run file which is a shell script.

sudo su
chmod 755 ./NVIDIA-Linux-x86-169.07-pkg1.run
./NVIDIA-Linux-x86-169.07-pkg1.run 

If the script cannot locate the kernel headers, make sure the linux-headers package for your kernel is installed, or, if you built the kernel yourself, make sure the /usr/src/linux symlink exists and points to your kernel sources. If that does not help, then specify the kernel headers like this:

SYSSRC=/usr/src/linux ./NVIDIA-Linux-x86-169.07-pkg1.run 

If the nvidia kernel module is not loaded, even after rebooting, try:

depmod -a
modprobe nvidia 

If you get an error like: "Error running install command", then remove /lib/linux-restricted-modules/.nvidia_new_installed, reinstall the driver and try again.

useful utilities

Additionally you may want to install the nvidia-settings command, which allows you to tweak your X settings.