Clone Your Ubuntu installation
Posted by admin on December 31st, 2006
Email This Post
Ubuntu uses the APT package management system which handles installed packages and their dependencies. If we can get a list of currently installed packages you can very easily duplicate exactly what you have installed now on your new machine. Below is a command you can use to export a list of your installed packages.
sudo dpkg --get-selections | grep '[[:space:]]install$=’| awk ‘{print $1}’ > installedpackages
Now you should end up with a file called “installedpackages” which consists of a long list of every package your currently have installed.
The next step would be to tell the clone machine to install each of those packages. You’ll have to copy that file to the clone machine (via network, usb drive, email, etc) and also make sure to duplicate the /etc/apt/sources.list file. Without the same access to repositories it may not be able to find the packages.
To tell your system to use the previously exported package list use the following command (after making sure to also clone your /etc/apt/sources.list file)
Update the source list using the following command
sudo aptitude update
Import the package list using the following command
cat installedpackages | xargs sudo aptitude install
If you want to be notified the next time we write something please subscribe to our RSS feed.Thanks for Visiting!


December 31st, 2006 at 6:57 pm
I kind of prefer this instead:
dpkg –get-selections > mypackages.txt
sudo dpkg –set-selections
December 31st, 2006 at 7:32 pm
The rest of that got left out.. Lets try it again:
dpkg –get-selections > mypackages.txt
sudo dpkg –set-selections < mypackages.txt
sudo apt-get dselect-upgrade
February 16th, 2007 at 1:17 pm
Your little snippet didn’t work for me, unless I removed the “equals”-sign.
….install$
=instead of this:=
….install$=
So:
sudo dpkg –get-selections | grep ‘[[:space:]]install$’| awk ‘{print $1}’ > installedpackages
March 3rd, 2007 at 12:07 am
Does this copy the packages or just makes a list for apt to go off of. I have a desktop with no way to access a network and a laptop with wireless and obvious mobility advantages. Is it possible to clone my installed packages off my laptop onto desktop with this method?
May 10th, 2007 at 6:45 pm
This just saves a list, so you’d need internet.
I am not sure but i think you could get the deb packages.
May 19th, 2007 at 1:01 pm
A simpler command can be
dpkg --get-selections | awk '/\Sudo is not needed when you generate the list, nor grep. Awk prints the first field of every line that contains the word "install" on its own (\
May 20th, 2007 at 8:57 pm
A had to include a -y switch on the second command to get it to work:
cat installedpackages | xargs sudo aptitude install -yJune 12th, 2007 at 3:08 pm
If you replace the install command with this:
xargs -a installedpackages sudo aptitude installyou won’t have to jimmy it past the abort with the -y option.
July 15th, 2007 at 7:50 pm
Can I do this and copy my home directory to the new computer? I am trying to get data, configurations, and everything. I can’t use partimage or anything else because I have a single broken package that has killed dpkg.
July 28th, 2007 at 9:19 pm
If you want to export your applications to a pc without access to the internet, Just make an apt on cd.
In the first pc (the one with internet) type:
sudo apt-get install aptoncd
then run the program, burn a cd with the apt and remember to configure the other pc to read repositories from the cd instead of the net.
August 7th, 2007 at 2:23 pm
Thanks Nelson. worked like a charm.
April 14th, 2008 at 9:03 pm
I saw these commands on another site.
Remember:
dpkg -l | grep ii | awk ‘print $2′ > remember_these_debs.txt
Reinstall:
sudo apt-get install `cat remember_these_debs.txt`
April 14th, 2008 at 9:25 pm
Rjack, your thought was incomplete…
dpkg --get-selections | awk '$2 ~ /^install$/ {print $1}'