If you’ve ever needed to upgrade Ubuntu versions, setup a new server or do any other type of migration, this is the easiest and most satisfying way to do it.. using Apt-Get!
First on our “old” server lets use apt-get to dump a list of installed packages to a packages.txt file:
dpkg --get-selections | grep -v deinstall > packages.txt
Then on the new server, lets update Apt-Get and install from our file:
apt-get update dpkg --set-selections < packages.txt apt-get -u dselect-upgrade
That’s it!