Yum install packages from text file
If you want to install packages from a text file using YUM, from server1 to server2, follow the steps below.
Let's create the text file with the listed packages on server1:
[root@server1]# rpm -qa > installed.txt
Then let's copy installed.txt from server1 using scp to server2, like this:
[root@server1]# scp installed.txt tom@server2:/home/tom
Now ssh to server2 and do this:
[root@server2 tom]# yum -y install $(cat installed.txt)
This will now install all the packages listed in installed.txt on server2. This has helped me out a few times and hope it helps anyone else out there too.
(N.B. This example was carried out on two Centos 5.6 servers but could easily work on other distributions. However, it goes without saying that each server will need to have the same architecture and distribution for this to work properly.)
August 8th, 2011 - 05:50
Hi Tom,
Nice to see a new post after all your travels!
‘yum list all’ will list *all* available packages, *not* what is installed. To get a list of what’s installed, use ‘rpm -qa’ which will list all installed packages. Once you have that piped into a file, use it on the second server in conjunction with yum… B-)
August 8th, 2011 - 06:49
Thanks Dan, glad someone is reading this thing
August 20th, 2012 - 20:44
‘yum list installed’ will list the installed packages. Thanks for the $(cat installed.txt) part that I needed for my how to!