Skip to content

Instantly share code, notes, and snippets.

@vwbusguy
Created June 8, 2019 04:50
Show Gist options
  • Select an option

  • Save vwbusguy/41595b50f6ff3e46a5951c844eb0d3a3 to your computer and use it in GitHub Desktop.

Select an option

Save vwbusguy/41595b50f6ff3e46a5951c844eb0d3a3 to your computer and use it in GitHub Desktop.
Remove duplicates after a botched dnf upgrade
# Use at your own risk! You should try `dnf remove --duplicates` first. Use this as a last resort.
sudo rpm -e --nodeps $(sudo dnf check 2>/dev/null | grep duplicate | cut -f1 -d' ')
@vwbusguy
Copy link
Author

worked for me, thanks mate :)

Awesome! Thanks for the feedback! 😃

@kiuhbit
Copy link

kiuhbit commented Dec 17, 2023

I think this fixed my system after it logged out mid-upgrade and broke things, thanks

@vwbusguy
Copy link
Author

@komakid
Copy link

komakid commented May 7, 2025

tells me… rpm: no packages given for erase :( but I have loads of duplicates…

@rhysnickerson
Copy link

With dnf5 it appears the output of dnf check has changed. Try running:
sudo rpm -e --nodeps $(sudo dnf check 2>/dev/null | grep duplicate | cut -f2 -d'"')
if you get no packages given to erase

@VRichardJP
Copy link

Just rescued my broken machine after a failed 40 -> 42 upgrade. Thanks a lot @vwbusguy!

@RoverBot-Dev
Copy link

my fault for not checking what packages this script removed before running it but it nuked my fedora install it doesn't even boot anymore. the files are fine it just removed every package it possibly could I think? anyway don't be like me check the output of sudo dnf check 2>/dev/null | grep duplicate | cut -f2 -d'"' before running rpm -e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment