Centos: How to install all packages of one server on another?

Itai Ganot asked:

I’ve done rpm -qa > file and now I want to copy the file to another server and run through it and install all these packages on the new server.
I did something like this: for pkg incat file; do yum -y install $pkg; done and it works but takes too much time, do you know a shorter way to achieve this goal? I do not have an automatic configuration manager software installed.
If I knew how to run through the file and switch the newline with just a space I could run it simply by: yum install -y pkg1 pkg2 pkg3 but I don’t know how to manipulate the data on the file so it will be displayed like that. (having spaces instead of newlines)

My answer:


No need to use xargs at all.

rpm -qa > file

yum -y install $(cat file)

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.