Debian APT configs and commands
I switched from Ubuntu to Debian so that I don’t need to update the code name in /etc/apt/sources.list
every time a
new release comes out. The following is some configs and commands I find useful.
1 | cat /etc/apt/sources.list |
Here I am mixing packages from multiple releases, which basically throws stability out of the window. However, by mostly
sticking to packages in stable
, one can get a system that’s stable enough but still access the latest release of
certain packages, e.g. clang
.
We need to tell APT to prefer packages from stable
over ones from testing
/unstable
in order to maximize the set of
stable packages. (There is a high confidence that packages in stable
play well with each other, but the same can’t be
said for other releases.) Such bias can be achieved easily with a larger priority score for stable
releases.
1 | cat /etc/apt/preferences |
Note that we are using priority <100
for packages from non-stable releases, which ensures that only packages from
stable
release will be upgraded via apt upgrade
or commands alike, because already installed packages have priority
100.
For installing and upgrading specific packages in non-stable releases, one can use apt install -t testing <package_name>
or apt install -t unstable <package_name>
. For example:
1 | apt install --dry-run -t testing neovim # using --dry-run to first see what will happen |
Occasionally, we might want to know what packages are installed from one specific release, e.g. unstable
:
1 | apt-show-versions | grep unstable |
or, what versions exit in different releases:
1 | apt policy clang |
§Deprecated
I was using the testing
release + Unattended-upgrade (u-u) with the hope of achieving a balance between stability and
an up-to-date system, but I encountered two problems serious enough to block my normal work (the first being some
packages are pulled into testing
, but its dependencies are still left in unstable
, and the second broke my
apt/dpkg
for unknown reasons). Therefore, I reinstalled my system and switched back to stable
release. Packages in
stable
don’t see many frequent updates, so I don’t have a use case for u-u anymore; the following u-u configs are just
for archiving purposes.
§u-u configs
As for staying updated, u-u has been working quite alright mostly with the following configs. However, when it does not,
I run sudo apt dist-upgrade
and it gets me out of trouble.
1 | cat /etc/apt/apt.conf.d/20auto-upgrades |
§APT timers
List apt-related timers:
1 | $ systemctl list-timers | grep apt |
apt-daily.timer
decides when to download upgradable packages, and apt-daily-upgrade.timer
decides when to perform
upgrade/cleanup. Since my network connection is rather slow, I prefer downloading happens during night, so I override
the default apt-daily.timer
with:
1 | $ sudo systemctl edit apt-daily.timer |
Then, we can confirm that our new config works fine with systemctl status
apt-daily.timer, the next trigger is around
3:00` next day.