Three different ways to duplicate installed packages in multiple machines in Linux

So you’ve installed your Linux server and installed all packages you need. Now you’re about to setup another server with similar packages. One thing you can do is to save the install commands from the first one and the run it on the second machine. How about when you’ve done it over few weeks time and forgot some details but need to have another server up and running quickly.

ssh root@remote.host "rpm -qa" | xargs yum -y install

This will duplicate installed packages from one machine to the other – works for rpm/yum based systems. The next one’s works for Ubuntu/Debian based systems.

Alternate command 1

apt-get install ssh root@host_you_want_to_clone "dpkg -l | grep ii" | awk '{print $2}'

This will clone a list of installed packages from one Debian/Ubuntu Server to another.

Alternate command 2

ssh remotehost 'dpkg --get-selections' | dpkg --set-selections && dselect install

This also works on Ubuntu that Copies the ‘install,’ ‘hold,’ ‘deinstall’ and ‘purge’ states of packages on the remote machine to be matched on the local machine. Note: if packages were installed on the local machine that were never installed on the remote machine, they will not be deinstalled by this operation.

Use WordPress.com, Twitter, Facebook, or Google+ accounts to comment (anonymous comments allowed)

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Privacy Policy on Cookies Usage

Some services used in this site uses cookies to tailor user experience or to show ads.