ubuntu – migrate packages from one server as a source to target server

The initial-status.gz and dpkg-query method from https://unix.stackexchange.com/a/80520/9132gives the most accurate and concise list for my needs.

comm -13 \
<(gzip -dc /var/log/installer/initial-status.gz | sed -n ‘s/^Package: //p’ | sort) \
<(comm -23 \
<(dpkg-query -W -f=’${Package}\n’ | sed 1d | sort) \
<(apt-mark showauto | sort) \




for i in `cat diff.txt`;do echo $i install >> selections.list;done; ———————-replace selections below:


  • On the source machine:
    cat /etc/apt/sources.list /etc/apt/sources.list.d >sources.list
    dpkg –get-selections >selections.list
    apt-mark showauto >auto.list
  • On the target machine:
    cp sources.list /etc/apt/
    apt-get update
    /usr/lib/dpkg/methods/apt/update /var/lib/dpkg/
    dpkg –set-selections <selections.list
    apt-get dselect-upgrade
    xargs apt-mark auto <auto.list


From <https://unix.stackexchange.com/questions/191662/how-do-i-replicate-installed-package-selections-from-one-debian-system-to-anothe>

List initial packages installed by ubuntu:

zgrep -E ‘^Package’ web_02_initial-status.gz | awk ‘{ print $2 }’ > web02_initial

From <https://askubuntu.com/questions/464701/find-out-what-packages-were-installed-after-os-install>

Leave a Reply

Your email address will not be published.



Get Free Shipping on Everything All Season Long
Best Buy Co, Inc.
Best Buy Co, Inc.