Ubuntu tip: Save a list of installed packages for reinstallation purposes

If you have a nicely running Ubuntu system with all your favourite packages installed, it might not seem like a good idea to start all over or to replace your hard drive. But here's a tip: To save a list of all packages that are currently installed! This should be a part of any good backup.

apt-cache --installed pkgnames

Save them in a file:

apt-cache --installed pkgnames > installed.packages.lst

To install all packages in a file:

sudo apt-get install `cat installed.packages.lst`