dpkg –set-selections: Clone your Ubuntu Machine (package state)
If you want to clone another machine in a similar way as one of your other machine, you can make use of dpkg command.
What does cloning mean?
Cloning a machine means installing the same packages (sometimes even settings) as found in the source machine. dpkg allows you to get the current state of your machine – the set of packages installed in the machine and their state (whether installed or uninstalled)
Suppose you have the list packages_list containing the state of the source machine.
Now go to the destination machine and run the following command
$ sudo dpkg --set-selections < ./packages_list
This command will not install any packages, but only mark a state corresponding to every package.
For the actual installation, run the following command
$ sudo apt-get -u dselect-upgrade
This will install all the necessary packages. Some packages may be removed. In the end, both the source and destination machines will have the same state
Comments:
Thanks a lot for putting this all helpful informormations into the web. One remark. I think package list will not work for distro-upgrade, let’s say from 9.04 -> 10.04 Ubuntu Version? There is a lot of people out, reading & not using brains 2.0 +++ Can you confirm this assumption? +++
Yes you are right, the packages_list contains only the package name. It may not be useful for distro-upgrade since it doesn’t contain version numbers of package