I want to have Server B to have exactly the same setup as Server A. Server A and B have the same Arch and same hardware.

My plan is to have a list of all installed things on Server A and install it by using the list on Server B something like :

yum -y install $(cat installed.txt)

In Server A, should I rather use:

rpm -qa > installed.txt


yum list installed > installed.txt  

The lists seem to be different and I have no idea why.

yum list installed has 930 lines while rpm -qa has 895 lines, what might be the difference?

  • Have you diffed the outputs (possible after sorting)? – Anthon Jul 23 '14 at 17:01
  • I don't have an idea on why there is a difference between yum and rpm output. May be you should try Anthon's suggestion and let us know what is the output. Also, for me both the commands list the same number of lines and as per your plan, I would go with rpm list since it has the list that can be used in your server b's yum command. – Ramesh Jul 23 '14 at 17:13
  • my bet : also because of packages installed by "rpm --install package.rpm" – Massimo Aug 20 '18 at 20:09

what might be the difference ?

The primary reason for the differing number of lines is that the output produced by yum is formatted so that each field lines up vertically (regardless of the length of the package name and/or version number). It does this by using two lines for listing such packages and padding the second line with space characters to line up the fields correctly. The following output (from a CentOS 6 box) shows that two lines are used to list the device-mapper-persistent-data.x86_64 package:

device-mapper-libs.x86_64         1.02.95-3.el6_7.4    @clearos-verified-updates
                                  0.3.2-1.el6          @clearos
dhclient.x86_64                   12:4.1.1-49.P1.v6    @clearos-verified-updates

However, this is not the only reason and it can be seen by massaging the output of the two commands before comparing them:

For the output of rpm command:

  1. Sort it so that packages beginning with an upper case letter appear before those with lower case:

    rpm -qa | LC_ALL=C sort
  2. Use a sed command to remove the package version numbers:

    rpm -qa | LC_ALL=C sort r | sed 's/-[^-]*-[^-]*$//' >| installed.rpm

For the output of the yum command:

  1. Remove the first two header lines (Loaded plugins and Installed Packages):

    Loaded plugins: etckeeper, fastestmirror
    Installed Packages

    We can use sed for this:

     yum list installed | sed '1,2d;'
  2. We can also use sed to remove all the lines that are continuations of a package listing (these lines begin with a number of spaces so that all the package versions line up).

    yum list installed | sed '1,2d;/^ /d;s/\..*//' >| installed.yum

Now, we can use the diff command to compare the output of the two files. Here’s the results from the CentOS 6 box:

# diff installed.{rpm,yum}
< gpg-pubkey
< gpg-pubkey
< gpg-pubkey
< gpg-pubkey
< gpg-pubkey


This shows that rpm -qa also includes package listings for the public keys that are trusted to sign packages while the yum command omits these packages.

  • some time ago but never too late for many thanks for your helpful analysis and conclusion !! – john Smith Jul 4 '18 at 20:57
  • @johnSmith Better late than never! :) I remember spending a bit of time on this one but I thought it was an interesting question. Answering such questions can be a good way of learning in itself. – Anthony G - justice for Monica Jul 5 '18 at 8:21

yum list installed has 930 lines while rpm -qa has 895 lines, what might be the difference ?

This is likely just formatting differences. yum list will do a bunch of clever wrapping to your terminal size.

What you probably want to do is use:

# Run this on the master server

# Run this on the new server, with the input from the above.
  • thanks for reply, after installing yum-utils on the new server and run "yum-debug-restore master_out.gz" it says for every package that its not available, am i missing something ? – john Smith Jul 25 '14 at 13:03
  • If they aren't identical servers (Eg. different arch, or the new one has older packages) you can use the --ignore-arch and/or --install-latest options on restore. – James Antill Aug 3 '14 at 21:13
  • I'll suggest to copy content of the master /etc/yum.repos.d/* to the new server before running yum-debug-restore – Sergey Vlasov Sep 10 '17 at 0:57

I'm not entirely sure why the lists are different, but I do know that rpm -qa > installed.txt is the correct way to find all of the installed packages. It will look for yum installed as well as rpm installed.

In addition, the format of rpm -qa output will work better with the yum install command that you are wanting to execute.


yum list installed gives me the output as below.

pam_krb5.i386                        2.2.14-22.el5                     installed

Now, rpm -qa has the below to say.


Both the commands give me the same number of lines as output. I would go with rpm -qa list.

Also, from this answer, I see the below piece of information.

there is the program, "rpm", which manipulates specifically the packages it is asked to manipulate, and there is "yum", which is a more intelligent management system that can find dependencies and download .rpm files even if they're not in the system.

So the difference might be yum resolves the dependencies but rpm has installed all the dependencies and so it provides a more complete list.

I see the actual difference between yum and rpm as below.

The most prominent problem with rpm is a state commonly referred to by most people as dependency hell. This problem occurs with packages that depend on a lot of other packages, some of those packages also depend on a lot of other packages. It is common knowledge that you must install all dependencies for the program to work correctly. rpm is unable to automatically do this for you. It can only check whether all the required packages are installed prior to installing the needed package. Manually tracking and installing each dependency is a major chore for most people who only want to install a single package initially.

yum is capable of tracking the dependencies of a package and installing them prior to installing the package that the user wanted to install. This simplifies the whole process as you need only know the name of the package that you want to install and not worry whether the required packages have been installed or not. Packages that can’t be found on the system are searched for in the repositories that are available to the system.



  • thanks for reply, for me yum list installed has 940 lines while rpm -qa has 895 lines , any idea what might be the difference ? – john Smith Jul 23 '14 at 16:54
  • @johnSmith, Yum handles dependencies and fetches packages to fill them. Yum runs effectively the same command as rpm but also includes all the packages needed to match dependencies. – Ramesh Jul 23 '14 at 16:56
  • yum is a godsend for managing package dependencies but that’s irrelevant when it’s simply listing the packages installed on a system. See James’ and my answer for the reason for the difference. – Anthony G - justice for Monica Dec 15 '16 at 12:33

yum list installed can create a two line output, if the package name and package version are long.

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.