dpkg –set-selections: Clone your Ubuntu Machine (package state)

Posted by Joys of Programming on in dpkg, Linux, Ubuntu

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

Tags: , , , , ,

Comments:

2 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? +++

  • Joys of Programming says:

    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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2009-2012 Joys of Programming All rights reserved.
Desk Mess Mirrored v1.8.1 theme from BuyNowShop.com.