In Debian, there's at least two ways to delete a package:

  • apt-get remove pkgname
  • apt-get purge pkgname

The first preserves system-wide config files (i.e. those found in "/etc"), while the second doesn't.

What is Fedora's equivalent of the second form, purge? Or maybe I should rather ask if yum remove pkgname actually preserves config files.


6 Answers 6


yum remove is not guaranteed to preserve configuration files.

As stated in the yum HOWTO:

In any event, the command syntax for package removal is:

# yum remove package1 [package2 package3...]

As noted above, it removes package1 and all packages in the dependency tree that depend on package1, possibly irreversibly as far as configuration data is concerned.


As James points out, you can use the rpm -e command to erase a package but save backup copies of any configuration files that have changed.

For more information, see Using RPM to Erase Packages. In particular:

It checks to see if any of the package's config files have been modified. If so, it saves copies of them.

  • 7
    That's not really true, "rpm -e" will remove the configuration files if they haven't changed. If they have been changed they are moved to <filename>.rpmsave and not deleted. Commented Mar 4, 2011 at 20:18

I found this answer to a duplicate question on ServerFault titled: yum equivalent of “apt-get purge" that provides the only method I've seen that can do what apt-get purge <pkg> does on Ubuntu/Debian.

for package in package1 package2 package3
  echo "removing config files for $package"
  for file in $(rpm -q --configfiles $package)
    echo "  removing $file"
    rm -f $file
  rpm -e $package

The only other method I can conceive of here is to parse the output from yum remove <pkg> and then manually delete any files that may have been modified. For example when I recently installed ElasticSearch's RPM for 2.3 I modified several files that were associated with this RPM. When I removed it with YUM you'll get messages in the output like this:

warning: /etc/sysconfig/elasticsearch saved as /etc/sysconfig/elasticsearch.rpmsave
warning: /etc/elasticsearch/logging.yml saved as /etc/elasticsearch/logging.yml.rpmsave
warning: /etc/elasticsearch/elasticsearch.yml saved as /etc/elasticsearch/elasticsearch.yml.rpmsave

These can be deleted post removal using YUM either scripted or by hand.


  • This might be an interesting dnf plugin....
    – mattdm
    Commented Jun 29, 2016 at 19:01
  • @mattdm - this issue has come up from time to time, would be nice if we could do this in the "RPM" world.
    – slm
    Commented Jun 29, 2016 at 19:23

There is no equivalent for "purge", just use yum remove package.

Also you can use yum reinstall package, when you want to reinstall some package...

  • 1
    Actually, as explained in Justin Ethier's answer, yum remove is equivalent to apt-get purge. Commented Feb 25, 2011 at 20:08
  • 8
    @Gilles Justin Ethier says yum remove is "not guaranteed to preserve configuration files." That's not the same as saying that it is guaranteed not to preserve configuration files (which would mean it is equivalent to apt-get purge). Are you making this (much) stronger claim? Commented Aug 30, 2012 at 2:15
  • @EliahKagan That's the way I understand the yum howto that Justin cites. I'm not sure that it's right, the CentOS seems to be saying the opposite. Commented Aug 30, 2012 at 2:27
  • 2
    I think it's undefined behavior. Yum may or may not preserve configuration files.
    – m0j0
    Commented Nov 7, 2018 at 18:09

For Fedora 31:


sudo dnf remove PACKAGE

Clean caches and other not needed files (not this is not the same as purge as far as I understood it)

sudo dnf clean all

To get more information about the command (before you execute the above):

dnf clean

This does nothing but show you the help screen for the clean command. Read also the manual, sometimes they are worth the time.

man dnf

For first time man users:

  • press / to start searching
  • type clean, press return
  • press n until you are in the section
  • note: In this case you could also just search for Clean Command but without knowing anything about the manual this would be not so easy.

See also:

  • /etc/dnf/dnf.conf -> setting clean_requirements_on_remove for a setting related to the asked operations
  • see man dnf.conf

    clean_requirements_on_remove boolean

    Remove dependencies that are no longer used during dnf remove. A package only qualifies for removal via clean_requirements_on_remove if it was installed through DNF but not on explicit user request, i.e. it was pulled in as a dependency. The default is True. (installonlypkgs are never automatically removed.)

  • https://dnf.readthedocs.io/en/latest/conf_ref.html


There is a purge plugin that works like apt; I use it often

sudo dnf purge package 

when you install it https://github.com/acidburnmonkey/dnf-purge-command

  • It is not enough to point to a tool, you should ideally also show how to use it to solve the given issue, i.e. how to do the equivalent of apt-get purge some-package on Fedora.
    – Kusalananda
    Commented May 24 at 21:22
  • is on the read me but ok
    – acid
    Commented May 24 at 21:34
  • "Links to other websites should always be helpful, but avoid making it necessary to click on them as much as possible." unix.stackexchange.com/help/how-to-answer
    – Kusalananda
    Commented May 24 at 21:38
  • The code you link to seems to only consider files in the user's home directory (apt would not delete files there) and would not delete configuration files installed by the package. The code is currently less than two weeks old (and full of spelling mistakes), which makes me wonder how often you actually use it and if it correctly does exactly what apt-get purge does.
    – Kusalananda
    Commented May 24 at 21:52
  • Also, if you are the author of the code, you need to say so in the text. See unix.stackexchange.com/help/promotion
    – Kusalananda
    Commented May 24 at 21:53

If you want to clean up config files from a program that you recently removed via an RPM system, all you have to do is enter: yum clean all

  • 3
    This is incorrect. The "yum clean all" merely cleans up cached metadata, mirror lists, etc., used by yum. It does nothing to configuration files.
    – m0j0
    Commented Nov 7, 2018 at 18:08

You must log in to answer this question.

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