Remove All NVIDIA Files

24,225

Solution 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}')

Solution 2

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

Solution 3

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-*'
Share:
24,225

Related videos on Youtube

christo8989
Author by

christo8989

Updated on September 18, 2022

Comments

  • christo8989
    christo8989 almost 2 years

    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?

    • drs
      drs almost 10 years
      Do you need to escape the * in your remove command? sudo apt-get remove --purge nvidia-\*
    • user
      user almost 10 years
      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.