How to save a list of installed packages (Debian)

May happen to have to re-install Debian (and derivates) in another pc/server
Certainly, if new machine has  a similar hardware i could clone hard disk; but more often the other machine has a different hardware…
So it is useful to save a list of installed packages; to have them immediately available during reinstallation in another (or in same) machine avoiding to remember  all packages one by one 🙂
As first thing is useful to make a copy of /etc/apt/sources.list or annotate  repository are you using   (wheezy, backports, etc) somewhere.

Open terminal (being root) and type:
dpkg –get-selections > /home/$USER/pacchetti.txt

At this way was created a file named “pacchetti.txt” in my  /home directory;
now you can save your file somewhere; for example, in an external usb drive,so you can use it when you’ll

How to restore packages:
Place file pacchetti.txt in your /home , then select packages in your file by typing:
sudo dpkg –set-selections < /home/$USER/pacchetti.txt
and install selected packages by typing  :
sudo apt-get dselect-upgrade
pacchetti2  Selected packages will be installed (obviously if missing).

This entry was posted in Gnu-Linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *