Repost: Source: Ubuntu Geek.
People sometimes have to do a reinstall of their Ubuntu system for various reasons (been playing/experimenting with configuration/drivers/other packages or just because something is badly broken) but remembering all the extra packages you have installed can be a chore – but here is the simple solution:
On your old system (assuming it is still working), start up Synaptic and go to:
File-Save Markings and choose a file name along with a location (like a USB drive) that you can use when you have installed your new system)
This file contains a list of all your currently installed packages, and when you have installed and booted up your new system (and configured your repositories to the best for your location ) then start up Synaptic and go to:
File-Read Markings and point it at your saved file, and after that has completed then select Apply to kick off the download & installation of all of those packages you had installed previously!
There are also apt-get command line functions that achieve the same outcome, so those who don’t have/use Synaptic can still do this.
You will still have to do any special configuration changes that you had on the old system, but at least all of the packages are now in the new system.
This is also very handy for moving to new hardware/duplicating setups etc.
Be aware that doing this between different Ubuntu versions may cause complications because some packages may not be in a later version or have different names.
Note:- Don’t forget to backup your sources before you reinstall.
sudo cp /etc/apt/sources.list ~/sources.list.backup
Otherwise if you have added any PPAs or other sources, this tip won’t work.