Remove All NVIDIA Files
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:
- Restart your computer
- Select
Advanced options for Ubuntu
at GRUB Boot Menu - Select
Ubuntu ..... (recovery mode)
- 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) - Select
root
(Drop to root shell promt at the Recovery Menu) - Type your root password
- Type:
apt-get remove --purge nvidia-*
- If finished type:
reboot
- 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-*'
Related videos on Youtube
![christo8989](https://i.stack.imgur.com/64IDp.jpg?s=256&g=1)
christo8989
Updated on September 18, 2022Comments
-
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: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 almost 10 yearsDo you need to escape the
*
in your remove command?sudo apt-get remove --purge nvidia-\*
-
user almost 10 yearsI agree with @drs. It's quite possible that your shell is expanding the
*
before it even gets toapt-get
. Escape it or quote it, and try again.
-