I have a CentOS 8.0 system with quite a few modules installed I don't want. I want to get rid of them to force an upgrade to CentOS 9.0, which I know is not officially supported but it is not actually what this question is really about. This question is only about this one step of removing all modules installed in dnf on my system.

The output from dnf module list was quite large, so I put it here: https://dpaste.com/EXMJLQ3VK

A lot of stuff installed on this system is no longer wanted and as you can see there is quite a lot of bloat that this would get rid of.

I would like to get parseable output from dnf on the modules list, and I also am not completely sure what I am supposed to do to remove them. On the Fedora wiki there is a page on using dnf modules but I can't seem to remove even just one from the list. I have tried things like this to remove modules...

# dnf module remove php:remi-7.4/common
Unable to match profile in argument php:remi-7.4/common

I of course don't actually want to remove each of these modules one at a time by hand, yet I can't find any way to get a parseable list from dnf nor even remove them manually. If I learn how to do both those things some magic with xargs is all it should take to remove every single thing in the list.

I did manage to disable every module by passing a wildcard to dnf like so...

dnf module disable "*"

Yet I cannot remove them with this same method...

# dnf module remove "*"
Last metadata expiration check: 2:20:13 ago on Wed 01 Jun 2022 10:32:56 AM UTC.
Error: Cannot enable more streams from module 'pmdk' at the same time
  • What happens if you try # dnf module remove php:remi-* or # dnf module remove @php:remi?
    – telometto
    Commented Jun 1, 2022 at 18:25
  • It doesn't work and gives this error missing groups or modules: php:remi-* and missing groups or modules: @php:remi
    – John Tate
    Commented Jun 4, 2022 at 8:41
  • Can you share the dnf list installed output?
    – K-attila-
    Commented Jun 7, 2022 at 13:53
  • dpaste.com/EXMJLQ3VK is dead. That's why is discouraged to just link relevant content.
    – robsch
    Commented May 25, 2023 at 12:51

3 Answers 3


I found a solution to this problem somewhere else.

You can remove the modules by deleting their metadata files from /etc/dnf/modules.d/

  • 1
    I'm not sure if that is good idea. That can leave your system in inconsistent state. How do you then know the system is ok?
    – tukan
    Commented Jun 18, 2022 at 19:25
  • I encountered this problem too and in the directory found only files for already removed packages. Removing helped me to continue with a system upgrade
    – MacHala
    Commented Dec 12, 2023 at 14:39

The Centos 9 moved away from the modules. It was probably not working properly in the first place

I tried to play around with the dnf module remove and I have to say it is buggy. It does not work as described.

Since your main purpose is to upgrade to Centos 9 I think your best bet is to disable all the modules, which you already did.

I understand you want to remove as many packages as possible, but I think this should not matter anyways.

  • This post explains things, I've left it for too long to give you the bounty. I will have to give this a test and see how I go.
    – John Tate
    Commented Jun 17, 2022 at 11:37
  • @JohnTate that is called points inflation ;). Give it a go, btw. in CentOS 9 they pretty much removed the modularity.
    – tukan
    Commented Jun 17, 2022 at 11:49

This is a hacky way, but you can loop over all the modules, remove all packages installed by each, and then reset them to default.

dnf module list | grep '\[d\]' | awk '{print $1}' | sort -u | xargs -I{} dnf module remove '{}' --all -y

dnf module list | grep '\[d\]' | awk '{print $1}' | sort -u | xargs -I{} dnf module reset '{}' -y

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .