How to install Nvidia drivers in Ubuntu 13.04

Updated: May 10, 2013

This is a very important tutorial. The last several releases of Ubuntu are less than stellar when it comes to installing Nvidia drivers on your machines. You are likely to end up with an unbootable system, just by using the same methods that used to work flawlessly in the past. To wit, this very detailed guide, which should save you a lot of trouble.

I will present you with no less than four methods, starting with the easiest and slowly escalating toward the more difficult and less obvious ones. We will also examine a few other techniques, tips and tricks, learn about recovery, backup, and more. This article should be your one stop shop for all current and future Nvidia drivers installations.

Nvidia teaser

How to recover, no matter what

Before we even begin, you need to know a few things, which should help you avoid any catastrophic loss of important, personal data, in case your system ends up not being bootable, usable or both.

Backups - Always keep backups of your personal files.

Imaging - If you can afford it, image your system, so you can restore it.

Keep a separate root and home partitions, so reinstalls become easy.

You can always boot from CD/USB and do repairs or data backups from there.

If you installed the drivers, and things are not really working, you can try to login via the first virtual console, Ctrl + Alt + F1, then perform maintenance tasks there. For example, if you installed the Nvidia drivers and they are not working, uninstall them. You might regain a bootable system.

Consider before any update

If you wish to install Nvidia drivers, you might want to do the following. Fully update your system, as well as install the so-called build essential tools, which include various compilers, kernel sources and kernel headers, to allow the proper installation.

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

Reboot if necessary. Then:

sudo apt-get install build-essential
sudo apt-get install linux-kernel-headers *

P.S. The name of the kernel headers meta package often changes. The names may include any one of the following: linux-kernel-headers, linux-headers-generic or linux-libc-dev, so you should be able to find your way around.

Method 1: Additional Drivers

The most trivial way of installing your Nvidia drivers. Open the Ubuntu Software Center, go to Edit > Software Sources, click on the Additional Drivers tab, select the desired version and click Apply Changes. I would recommend using the latest updates. Demonstrated on Xubuntu 13.04 Raring Ringtail.

Installing Nvidia drivers

Nice desktop, with Nvidia settings panel

Method 2: Manual install from repository

This is pretty much like we did in Quantal Quetzal. Go to one of the virtual consoles and perform all the commands there. P.S. If you're still logged into your machine and not facing any problems yet, i.e. working normally on your desktop, then you can do the first two steps from any terminal window.

sudo apt-get install build-essential linux-source linux-headers

If the transitional package linux-headers is not available, instead, please try running the command by specifying the exact version of the headers with:

sudo apt-get install linux-headers-`uname -r`

The name may also change to linux-kernel-headers, linux-headers-generic or linux-libc-dev. They all point to the same package, so you should be fine. Next, install the current version of the Nvidia driver:

sudo apt-get install nvidia-current

You may also want to consider the nvidia-current-updates package. Once the installation completes successfully, check if the Nvidia driver is loaded:

sudo /sbin/lsmod | grep nvidia

If it's not, you will need to manually insert the driver into memory. First, make sure all kernel module dependencies are satisfied and resolved:

sudo depmod -a

Then, load the driver:

sudo modprobe nvidia_current

This should succeed and the lsmod command should show it's loaded, but the usage count will probably be 0, because nothing will be using it yet. You will need to restart the graphics environment to actually benefit from the driver:

sudo /etc/init.d/lightdm restart

One more thing that you may want to consider, before loading the driver, is to run the Nvidia graphics configuration tool, which will create an Xorg.conf file containing the correct settings for the use of the driver on the startup of the graphical session.

sudo nvidia-xconfig

Method 3: X-SWAP unofficial PPA

You might want to consider using an unofficial repository for your graphics card installations and updates. This is not the best option, but sometimes, unofficial sources can actually offer better results than the official ones, which is kind of sad and funny.

sudo apt-add-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install nvidia-current

Method 4: Manual install from the official site

This is very old school, much like we often used to do in openSUSE and CentOS in the past. Indeed, I will recommend you take a look at my CentOS guide for detailed instructions how to achieve this.

Basically, it comes down to this: Grab the official driver from the Nvidia website. Install all upgrades and build tools. Switch to a virtual console. Shut down the graphics environment with sudo /etc/init.d/lightdm stop command. Then, navigate to the the directory where you downloaded the official driver and run:

chmod +x <Nvidia file>.run
sudo ./<Nvidia file>.run

Once finished, start lightdm and that's it. The downside of this method is that you will have to reinstall the driver every time there's a kernel update, and you will not be getting any automatic updates for it. But it's preferable to having a machine with a graphics card worth hundreds of dollars and not being used properly. Or you could switch to another distro.

Other tips and tricks

The following information might come handy in case none of the options mentioned above works, and now you're in that stage called despair tinkering level 9, so you might as well considering trying some of them. Most of these tricks should be done in a virtual console, which you can reach with Ctrl + Alt + F1-6. You should consider stopping the desktop environment with:

sudo /etc/init.d/lightdm stop

Nouveau & Nvidia conflicts

Do note that this is a somewhat bruteforce blacklisting of modules, and might not work. It can be useful if you keep having conflicts between Nouveau and Nvidia drivers, and you want to install the latest version of the driver, provided by the nvidia-current-updates package. As sudo or root, edit the following file:


Populate the following file with following information:

# This file was installed by nvidia-current-updates
# Do not edit this file manually

blacklist nouveau
blacklist lbm-nouveau
blacklist nvidia-173
blacklist nvidia-96
blacklist nvidia-current
blacklist nvidia-173-updates
blacklist nvidia-96-updates
alias nvidia nvidia_current_updates
alias nouveau off
alias lbm-nouveau off

Recreate the initrd file:

sudo update-initramfs -u

Add/edit the following to your GRUB2 default config under /etc/default/grub:


Test and enjoy!

If you're successful, then you can begin enjoying your machine.

Nvidia, Steam

More reading

You might want these guides, too:

Highly useful Linux commands & configurations

Ubuntu 12.10 Quantal Quetzal review on a machine with Nvidia card

A lengthy Xubuntu 13.04 Raring Ringtail review


I believe this is a highly useful tutorial, which teaches you a lot of things, in addition to its core mission of installing the graphics drivers for your Nvidia card on Ubuntu. The tutorial is also applicable to Kubuntu and Linux Mint, with the one exception being the names of the graphics environment, kdm and mdm, respectively. Anyhow, you have four methods, plus a manual hack to achieve the desired task, plus tips and tricks on compilation, working with sources and unofficial repositories, recovery, backup, virtual consoles, and more.

Overall, you should be fine, and the normal install ought to work, but if you get in a tight spot, you will know how to extricate yourself elegantly and painlessly. I guess that would be all. If you feel there are things missing from this tutorial, additional tips and tricks that can be added, and yet other, more inventive and innovative methods, feel free to ping me. I will keep sacrificing myself so you don't have to. Stay pretty.

P.S. If you find this article useful, please support Dedoimedo.