brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: apt-get -d upgrade downloads everything first, so the real upgrade is quick

Apt
~/tips/tip-apt-get-download-only-upgrade

sudo apt-get -d -y full-upgrade

Fetches all upgrade packages ahead of time without installing anything.

On a slow or metered connection, an upgrade spends most of its time downloading while services sit half updated. I’d rather download everything first and install when I’m ready.

The -d flag, long form --download-only, fetches the packages into the cache and stops:

sudo apt update
sudo apt-get -d -y full-upgrade
ls /var/cache/apt/archives/*.deb | wc -l

Nothing is unpacked or installed. Later, in your maintenance window, run the normal sudo apt full-upgrade. apt sees the files are already in /var/cache/apt/archives and goes straight to installing.

It works for single installs too, like apt-get -d install postgresql-16, which grabs the package and every dependency it needs. That’s different from apt download, which only fetches the one .deb into the current folder without dependencies.

The -y is safe here because nothing gets changed, only downloaded.

Two things to watch. If you run apt update again before installing and a newer version appeared in the meantime, apt downloads that one too and your cached files are partly wasted. And the cache keeps growing, so after upgrading, apt-get autoclean or apt clean gives the space back.

Further reading: apt-get(8) manual page

More Apt tips sudo apt-mark minimize-manual apt list '~c' grep -E ' (install|upgrade|remove) ' /var/log/dpkg.log | tail -o Dpkg::Options::="–force-confold" upgrade apt show nginx All Apt tips (42) All topics

Link