Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wrote a script which along other tasks connects to a remote server and pulls a list of all installed packages and installs them, Like so:

echo -e "\e[36m#===# Getting list of packages to install #===#\e[0m"
$ssh root@$srv 'rpm -qa --queryformat "%{NAME}\n" >/tmp/sw.lst'
$scp root@$srv:/tmp/sw.lst /tmp/
np=`cat /tmp/sw.lst |wc -l`
echo -e "\e[36m#===# $np Packages are going to be installed! #===#\e[0m"
/usr/bin/xargs yum -y install < /tmp/sw.lst

My problem is that when it runs through the list it skips many packages which came with the default installation and i'm trying to save that time, is that possible?

share|improve this question
up vote 1 down vote accepted

I'd simply do a

ssh root@$srv 'rpm -qa' | xargs yum -y install

and the go get some coffee or something, because to find a solution which is

  1. quicker
  2. works considering each machines individual packages

you'd still have to do something like comparing both machines rpm -qa and sort it, run the comm trick like SvW suggested and finally use that list for a yum install...

why not just let yum figure that out?

Or better yet, why not have a frozen repo which all boxes are connected to, and then kickstarting new installations (using cobbler/foreman/spacewalk/what-have-you)? You'll then know each package installed from the beginning, and every system will look the same (or similar enough)? To keep the systems in sync, I'd use puppet and specify the list of packages which should be installed there... -- Then this situation won't appear in the first place; since you want to save time using this, I figure you do this a lot...

share|improve this answer

There is no way I know of to detect that this package was installed during the OS setup and this list can vary depending on the options you select during install time.


  • Create a similar list for a base install.
  • Make sure both lists are sorted (man sort)
  • use comm to display only lines not in both files

    comm prodinstall.txt  baseinstall.txt -2 -3 > install.txt
  • install.txt will now contain only the packages not in the base install.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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