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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s