1

Background: I bought an NVIDIA graphics card and tried to install its driver. Somewhere along the way I messed up and now I'm running my computer on Cinnamon backup mode (I have Ubuntu but I removed Unity and replaced it with Cinnamon). I want to start back from scratch (prior to this, I was using a core i3 and no graphics card).

Problem: When I enter sudo dpkg -l | grep -i nvidia I get a list of results:

Results

But when I enter sudo apt-get remove --purge nvidia-* it says I have no matches found.

I've tried a couple of other different ways with similar results. Again, I want to start fresh by removing all unnecessary files.

How do I remove all unnecessary nvidia files?

  • 1
    Do you need to escape the * in your remove command? sudo apt-get remove --purge nvidia-\* – drs Jul 16 '14 at 14:42
  • I agree with @drs. It's quite possible that your shell is expanding the * before it even gets to apt-get. Escape it or quote it, and try again. – a CVn Jul 16 '14 at 14:45
1

It's not particularly useful here (where you can just fix your escaping as commented) but in the case where you want to search the whole dpkg -l line, you can run it through something like awk and then into apt-get purge with minimal conditioning:

sudo apt-get purge $(dpkg -l | awk '$2~/nvidia/ {print $2}')

That should prompt you before it does anything but just in case, you could test it with:

apt-get -s purge $(dpkg -l | awk '$2~/nvidia/ {print $2}')
1

The problem is that * is being expanded by your shell before it is passed to apt-get. You probably have a file or directory in your current directory whose name starts with nvidia- and that is being passed to apt-get. To illustrate:

$ ls -l
-rw-r--r-- 1 terdon terdon 0 Jul 16 17:22 nvidia-foo

$ sudo apt-get -s purge nvidia-*
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package nvidia-foo

That's because what is actually being run is sudo apt-get -s purge nvidia-foo since nvidia-* is expanded to nvidia-foo before being passed to apt-get. This is why you should always quote your globs:

$ sudo apt-get -s purge 'nvidia-*'
1

If you have only access to GRUB:

  1. Restart your computer
  2. Select Advanced options for Ubuntu at GRUB Boot Menu
  3. Select Ubuntu ..... (recovery mode)
  4. Select dpkg Repair broken packages at the Recovery Menu (this will stop the nvidia processes so we can uninstall). Choose Yes. When finished press ENTER (even if it found problems)
  5. Select root (Drop to root shell promt at the Recovery Menu)
  6. Type your root password
  7. Type: apt-get remove --purge nvidia-*
  8. If finished type: reboot
  9. Boot as usual, it should go to your Ubuntu Login screen now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.