51

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.

28

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.

| improve this answer | |
  • 5
    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. – James Antill Mar 4 '11 at 20:18
9

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

| improve this answer | |
  • This might be an interesting dnf plugin.... – mattdm Jun 29 '16 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 Jun 29 '16 at 19:23
1

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

| improve this answer | |
  • 1
    Actually, as explained in Justin Ethier's answer, yum remove is equivalent to apt-get purge. – Gilles 'SO- stop being evil' Feb 25 '11 at 20:08
  • 6
    @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? – Eliah Kagan Aug 30 '12 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. – Gilles 'SO- stop being evil' Aug 30 '12 at 2:27
  • 1
    I think it's undefined behavior. Yum may or may not preserve configuration files. – m0j0 Nov 7 '18 at 18:09
0

For Fedora 31:

Uninstall:

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

| improve this answer | |
-2

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

| improve this answer | |
  • 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 Nov 7 '18 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.