If you want to create a system that is similar to a different system you have already set up, it can be difficult to remember each and every package you had installed.This method works best when you are exporting to and importing from the same distribution and, specifically, the same releasefor example, exporting from Ubuntu Dapper to Ubuntu Dapper or ubuntu edgy to ubuntu edgy.

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.

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)

that sounds good, I was looking for something like that, but as a real basic user, I’d have two questions :
1 – what if we have uninstalled something from the vanilla ubuntu installation ? Will it get uninstalled as well with these scripts ? Or just ignored by the script and therefore left on the target system ?
2 – I see several scripts here above, in the article and the comments, all Chinese to me. I’m good only at copy-pasting, is there one that you gurus agree is better than the others ? (as in, more robust ?)

If you do a fresh install, you need to do a fresh install of all your packages as well. Sorry, but in theory it sounds great, but in practice does not work. The list is so long that you don’t know what your installing, and the config files will all be new as well. Sorry, but in my opinion, there is no easy way to re-install all the software from an old system to a fresh new install. You would spend much less time just doing it all over again. Keep a simple text list of programs that you really need and go from there. Even then, things will change. Change is the only thing you can count on…

@RickBragg.
I think the dpkg method is effectively a fresh install over the new system of a list of (presumably kept up to date) packages. The list is only a list of each package to install, not the code.
However on the config side, you are correct I think. Without some way of collecting (from no well defined place) all the config files anyone using this will be lost.
@ALL
BUT… for ubuntu there is ‘remastersys’ you can create a snapshot of a working install onto a live DVD. I think (though I’ve not tried it) it also allows you to select install to disk, effectively cloning your system.http://www.geekconnection.org/remastersys/

That ” grep ‘[[:space:]]install$=’ ” part actually returns nadda. So then printing $1 is useless. The result is a blank file. dpkg –set-selections > installedpackages seems to work best.

Then on the target system, not sure what ‘cat installedpackages | xargs sudo aptitude install’ would have done but “dpkg –set-selections < installedpackages" followed by "apt-get -u dselect-upgrade" seemed to work much easier.

Also, @RickBragg, it's all subjective to your specific needs. I spent hours with a fresh 10.04.2 installation installing packages and learning which packages were needed, which weren't, removing unneeded packages, etc. no 'custom configuration' but getting my package list right. I also had installed perl modules from aptitude and after testing our application, learned which ones were needed, it took the better part of 2 hours of testing to learn all the various modules that were needed. I then cloned that server to 4 physical servers using a disk image, this was easiest. But then, I wanted to test various use cases but couldn't use a real physical server to do this, so I created a Virtual Server. However the specs are too radically different for me to just restore my image, so I did a clean Ubuntu 10.04.2 install on the virtual server and rather than go through my history on one of the physical servers and see what I did and didn't install, etc. etc. I just used this method. Like I said, specific use examples.

I very strongly recommend remastersys for three reasons particularly for the desktop systems.
1. You have a snapshot of your system as a backup
2.You have an installation media with all your packages on it. Thus no need to download them again.
3.You save bandwidth and reduce load on the download server