I am using yum to install a patch update on my RedHat Linux machine,

Is it possible to use yum on different way in order to uninstall unused rpms/patches?

My goal is to remove the unnecessary rpm/patches in order to free some space in my partition


I find the following command to remove old rpm kernel

 (package-cleanup) from - yum install yum-utils

 package-cleanup --oldkernels --count=1
  • If you have some old packages which isn't required by the system it gets cleaned by the yum. e.g old kernel. http://www.if-not-true-then-false.com/2012/delete-remove-old-kernels-on-fedora-centos-red-hat-rhel/
    – AReddy
    May 10, 2016 at 8:00
  • sorry - but I don't get you , do you mean that every time that I use new yum install - its actually remove the old rpm?
    – yael
    May 10, 2016 at 8:02
  • Check the link it says that there is a limit installonly_limit=2 which can be mentioned in the /etc/yum.conf
    – AReddy
    May 10, 2016 at 8:04
  • about to remove old kernel - yes I know how to do that , what I ask is how to remove old rpms that isnt used by the OS (linux)
    – yael
    May 10, 2016 at 8:10
  • you can use yum clean all
    – Ijaz Ahmad
    May 10, 2016 at 8:19

4 Answers 4


When you install new updates with yum, the original installed packages and binaries are updated. It doesn't keep multiple copies of them around. It does cache various things however.

You can use various yum clean options to tidy up some of yum's own cache files.

For example, yum clean packages will remove cached packages that have been downloaded, some of the other options may be helpful but often yum will just rebuild the data on next execution.

man yum will provide you with information on the other clean options.

  • This will clear the cache not the old package.
    – AReddy
    May 10, 2016 at 8:06
  • about yum clean - please advice what actually this clean ? ( installed rpm? , binaries ? )
    – yael
    May 10, 2016 at 8:11
  • @yael - The only way to remove installed rpm's is to use the yum remove option. May 10, 2016 at 8:32
  • @Mongrel I clearly state it removes cached packages. May 10, 2016 at 8:33
  • Right, but this is not the answer.
    – AReddy
    May 10, 2016 at 9:25

I'd suggest two approaches to determine which packages can be removed:

  • do a minimal installation with the RedHat release in question (which you didn't mention, by the way) and only add the packages on top which are mandatorily required for what this machine is intended to do.
    Then get the listing of all packages by name (so you could easily compare to packages with slightly newer/older versions) via rpm -qa --qf="%{N} \n" | sort > minimal_install Then create a backup of your machine you want to "clean up" and remove all the packages which are not on the list minimal_install after a thorough review.

  • sort your packages by size, and try to remove some of the packages on top of the list, to get most diskspace savings with least packages. Get the list via e.g. rpm -qa --qf '%{size} \t%{name}\n' | sort -n > packages_sorted_by_size

  • actually check what is using up most of the diskspace, can be easily checked via e.g. du -mx /|sort -rn|head -35 and if /usr is not all over the top of the list, then the rpm packages should not be your priority for cleanups.


Running the "yum update" operation will update any packages that are on the system.

Specifically that means: Downloading new version Checking new version's download. Installing/Updating new version Checking new version's installation

The old package is not installed any longer, just the new one. Depending on what extensions you have, you likely will only have the rpm file(s) on the disk and a "yum clean all" will remove them, along with the repository metadata, which will get regenerated on next yum operation.

Also, if you are only interested in updating firefox (for example), you can issue a "yum update firefox" command, and that will restrain updates to firefox and any dependencies that are required to get the new update to firefox installed.

As for an aforementioned incremental update, those are drpms (delta packages) and are just that -- the change in package contents from your installed version and the update this should be enabled on RHEL7/Fedora for any repository that offers them. RHEL6 needs the yum plugin "presto" to be installed to take advantage of it, again with any repos that support it.


RPM packages does not contains incremental updates (as contrary to e.g. Solaris). So every package contains everything needed for both upgrade and clean install.

When you call

yum install firefox

And firefox is already installed then yum should refuse to proceed even when there is newer version available. You should call:

yum upgrade firefox

This will install new version of the package, and them remove the old package automatically. So no left over should remain on your system.

Though you can call:

yum install http://foo.bar/firefox-40-1.rpm

and if it is newer then currently installed package, then yum automatically convert it to yum upgrade command.

And there is one other exception – kernel.

yum install kernel

will install new kernel (when available), but will not remove the old one (so you can boot to old one, if the new one does not work). In fact it apply on few other packages too. I will quote from man page of yum.conf:

installonlypkgs List of package provides that should only ever be installed, never updated. Kernels in particular fall into this cat- egory. Defaults to kernel, kernel-bigmem, kernel-enterprise, kernel-smp, kernel-modules, kernel-debug, kernel-unsupported, kernel- source, kernel-devel, kernel-PAE, kernel-PAE-debug.

Note that because these are provides, and not just package names, kernel-devel will also apply to kernel-debug-devel, etc.

installonly_limit Number of packages listed in installonlypkgs to keep installed at the same time. Setting to 0 disables this feature. Default is '3'. Note that this functionality used to be in the "installonlyn" plugin, where this option was altered via tokeep. Note that as of version 3.2.24, yum will now look in the yumdb for a installonly attribute on installed packages. If that attribute is "keep", then they will never be removed.

So you can have up to 3 kernel packages installed concurrently. But not 4 as yum will start removing them automatically. As you stated – you can remove old kernels by package-cleanup --oldkernels if you really want to.

There is no need to do anything similar for normal packages as yum do that every time during upgrade transaction.

You can verify it by running:

rpm -q kernel

which will likely list 3 package. While

rpm -q httpd

Should list only one package. And

rpm -q glibc

will likely list 2 packages on 64bit machine – one x86_64 and other i686 if you have some packages which requires multilib (e.g. wine).

  • Regarding the the first line, that is not correct, newer Fedora/CentOS versions and also openSUSE use delta RPMs since quite some time, and those are only differential updates. See e.g. fedoraproject.org/wiki/Features/Presto and en.wikipedia.org/wiki/OpenSUSE#Default_use_of_Delta_RPM
    – doktor5000
    May 11, 2016 at 17:02
  • That is correct, but applydeltarpm applies a binary delta to either an old rpm or to on-disk data to re-create a new rpm. This will result to normal full rpm package, which is given as the starting point for rpm transaction.
    – msuchy
    May 12, 2016 at 11:09

You must log in to answer this question.

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