Firstly, go to the official nVidia website and download the official linux drivers. Of course nv's nice and all.. but I wouldn't use it over the real thing. Once you download the driver file (into your home folder), right click on it in nautilus (file browser), click properties, then permissions, checking the box that says "allow executing the file", then type into a TTY session ctrl+alt+f1-f3 (ctrl+alt+f7 to get back to GUI) and type in
sudo /etc/init.d/gdm stop
Which will stop your x-server.. (DON'T DO ANY OF THIS UNTIL YOU KNOW THE WHOLE PROCESS, BECAUSE TURNING BACK ON YOUR GRAPHICS COMES AT THE END!)
(Also note that this will be a text-only display! Remember or write down all the commands.) then hit
ls
to list the files in your home folder. Find the one with "nvidia" in it, and hit "sudo ./*nvidia filename*" it should install the "nvidia" driver on your computer. when it asks you whether or not you want to replace the existing "xorg.conf" file, let it do so. once that's done, type in "sudo /etc/init.d/gdm start" which will turn back on the graphical interface, allowing you to login again. (sorry. it logs you out of everything but the commandline part of ubuntu. save everything before you turn off gdm.) If your controls work perfectly in regards to the mouse and keyboard, rejoice, you're done! if your mouse isn't scrolling, or it's behaving funny.. you may have to hit alt+f2 (You'll still be in graphical mode after hitting this one. it's a nice little tool.), and type in
gksu gedit
then open your xorg.conf file (Usually in the "/etc/X11/" folder), looking somewhere other than me about how to fix that, if copying your "pointer" section doesn't fix it.
(Copying the pointer section worked for me, since I had it set up right in a previous xorg.conf file..)
Now, in case of kernel update, remember that the nvidia driver will NOT work without reinstallation. This is expected, so expect it. In this case, you'll be in CLI mode. Your previous driver installer will work just fine, I like to check for updates occasionally, just to be with the newest version.
Always make sure, with a new executable comes making it executable before trying to.. well.. execute it. With GDM (the graphical display) working, simply right click the file in the file browser and click properties, set it executable. In CLI: have the file in your home directory or know the directory it's in.. Then do "cd "/path/to/driver/" before finally setting it executable. Do this with "sudo chmod a+x "{driver file name}"" (You can use the ls command to once again list it exactly).
Now, execute the file by simply typing the filename into the command line. It will say there's a previous version installed, and ask to write over it. Do so. It shouldn't need to overwrite the xorg.conf file, as the NVIDIA driver's still being used. Don't let it and save some hassle.
So basically, set the file executable in the file browser, or use sudo chmod a+x "nvidiadrivernamehere", stop gdm if it's started (sudo /etc/init.d/gdm stop), then execute it, overwriting the driver, but not the xorg.conf. Then, start GDM back up (sudo /etc/init.d/gdm start)
If you overwrite the xorg configuration file (conf) just restore the backup. Look in the file browser (using alt+f2, typing in gksu nautilus and executing to get a root file browser. Needed for editing /boot/ files.) in "/boot/grub/" in list mode for the latest thing resembling .backup or .bak1 or something, listing files by date changed. delete the new xorg.conf, changing the name of xorg.conf.bak to xorg.conf.
So, in essence,
1: Download driver. Set as executable.
2: turn off graphics, going into only command line.
3: list files, execute driver installer.
4: follow installer's instructions, allowing it to replace your xorg.conf.
5: restart gdm. Hope everything goes smoothly.
6: *contingent upon condition in last step being met* DANCE! YOU WIN!
To reinstall,
1a: change file to executable if gdm's booted up through the properties prompt.
1b: do a sudo chmod a+x {filename} if it's not.
2a: kill gdm server (sudo /etc/init.d/gdm stop in CLI (ctrl+alt+f1)) proceed to 2b.
2b: execute file. (sudo ./NVIDIA-x86-173.x.x-pkg1.run (or -x86_64-))
3: Follow prompts, letting it overwrite the old driver. Don't let it overwrite xorg.conf unless it's been changed to use another driver.
4: Start gdm. (sudo /etc/init.d/gdm start)
5: Rejoice! If it worked before, it should work now! If it doesn't, despair. Boot from a livecd if you have one, or use a computer at a library to come here and flame me. It happens frequently.