What is Fedora's equivalent of 'apt-get purge'?

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.

Update

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.


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
do
  echo "removing config files for $package"
  for file in $(rpm -q --configfiles $package)
  do
    echo "  removing $file"
    rm -f $file
  done
  rpm -e $package
done

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.

Reference

  • https://serverfault.com/a/41519/2518

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...