To get the installed packages list:
dpkg --get-selections '*' > /tmp/selections.txt
To re-download the installed packages on the machine with internet access:
apt-get clean
awk '$2=="hold" || $2 == "install" {print $1}' /tmp/selections.txt |
xargs -r apt-get -d -y reinstall
This will will download all the installed packages into /var/cache/apt/archives/
. xargs
is used here in case the list of installed packages is too large to fit on one command line.
Note: running apt-get clean
is optional. It will delete all .deb
files that were already in /var/cache/apt/archives
. This is done only to minimise the number of packages that will need to be copied to the non-internet machine (e.g. old versions, uninstalled packages, etc that are still present in that directory). The downside is that all installed packages will be downloaded again, even if they were already in the archives directory.
Copy /tmp/selections.txt
to /tmp/
on the non-internet machine.
Copy everything in /var/cache/apt/archives
to the same directory on the non-internet machine. The method doesn't matter - scp, rsync, USB stick, external hard-drive, whatever. The important thing is that they are copied to /var/cache/apt/archives
on the target machine.
on the target (non-internet) machine run:
dpkg --set-selections < /tmp/selections.txt
apt-get dist-upgrade
If you want the apt-get dist-upgrade
to uninstall packages that were previously installed on the target machine but NOT installed on the other machine, then run dpkg --clear-selections
before running dpkg --set-selections
.
See the dpkg
man page for more details about the --get-selections
, --set-selections
, and --clear-selections
options.
dpkg -l | awk '/^ii/ { print $2 ;}'
should get you a list of fully installed packages. – icarus Jul 12 '19 at 02:32