This is a short note for those who miss this option after moving away from a Debian-based system, or those who did not even know that such an option exists.

Less flexible option, working on almost every yum version

There is a (hidden) configuration option that can be placed into /etc/yum.conf that will force yum to remove all unused dependencies every time you uninstall a package. For some this option may work well, as most people do not need any packages that are not required by any other installed packages, but some (e.g. developers) may find this option to be too strict, as it may remove some packages that are implicitly required by self-installed or self-compiled programs.

Open /etc/yum.conf (as root), and place the following line at the end:

clean_requirements_on_remove=1

Now, every time you remove a package, all installed dependencies that are not required by other packages will be removed as well.

More flexible option, supported by the most recent yum versions

The most recent versions of yum introduced a more convenient way to clean the system when removing a package. Instead of yum remove package use the following:

yum autoremove package

Now, this option allows you to autoremove dependencies only when you really need this.

Additional cleaning

In addition, whenever you feel something might have gone wrong, you may want to run the following command:

yum clean all

This will clean all yum metadata, headers, and cache, so that the next yum command will start from scratch.

Notes

  1. Suppose an installed package A requires packages B, C and D, and D is the only one required by some other packages as well. Then, auto-removing either package A or, say, B will result in removing packages A, B and C.
  2. Earlier versions of yum used a plugin called yum-plugin-remove-with-leaves, which could have been installed via repositories and used as follows: yum remove --remove-leaves package. Note, that this plugin is reportedly said to cause issues.
  3. When a package is installed using yum localinstall, I believe, the result of the yum autoremove is unpredictable. At least, it may produce errors sometimes.