主题: apt
-
将 Debian 和 Ubuntu 升级到下一个主版本,同时保留回退途径
Ubuntu 的 do-release-upgrade 和 Debian 先手动修改软件源列表再升级的流程,都以完整备份和备用控制台访问为前提,以应对升级中途 SSH 会话断开的情况;Debian 自己的发行说明建议先进行最小升级,再进行完整升级。
-
以当前方式添加第三方 APT 仓库:deb822 .sources 文件与 Signed-By 密钥环
apt-key 已弃用;受支持的添加签名第三方仓库方式,是在 /etc/apt/keyrings 下放置密钥环文件并用 Signed-By 选项引用,配置可写成传统单行形式或较新的 deb822 .sources 格式,Debian 12/13 和当前 Ubuntu 版本都能解析。
-
An internal package mirror or cache for Linux clients: apt-cacher-ng and dnf's reposync
Apt-Cacher NG caches Debian/Ubuntu packages on demand behind an HTTP proxy setting, while dnf's reposync plugin makes a full local copy of a chosen RPM repository. Both cut repeated downloads without weakening client-side signature verification, which stays on regardless of where the bytes came from.
-
apt-get, dpkg, dnf and zypper exit codes: when 100 means updates, not failure
apt-get uses a flat 0-success/100-error split; dpkg distinguishes a failed check (1) from a fatal usage or system error (2); dnf's check-update repurposes 100 to mean updates ARE available, not an error; and zypper defines a whole range, 100-107, of informational (non-error) exit codes for conditions like a pending reboot (though 104, package not found, and 105, interrupted, mean the action did not happen). Reading any of these as a plain success/fail boolean loses real information.
-
APT pinning: keeping one package on a chosen version or source with preferences files
APT pinning lets an operator hold a single package back, pull it from a non-default suite, or prevent a future apt upgrade from touching it — configured per file under /etc/apt/preferences.d rather than by editing one shared file, and inspected with apt-cache policy.
-
Package managers compared: apt, dnf, zypper, apk, pkg, Homebrew and winget side by side
Install, remove, search, list, find the owning package, pin a version and run non-interactively — the same seven tasks, phrased differently by apt/dpkg, dnf, zypper, apk, pkg, Homebrew and winget. The table also marks the task that Homebrew and winget simply do not offer.
-
Running apt and dpkg non-interactively on Debian and Ubuntu without hanging on prompts
A scripted apt-get or dpkg run can stall on a debconf prompt, a modified-conffile question or a held dpkg lock. Setting DEBIAN_FRONTEND, the right confold/confdef options and preseeding debconf answers first turns an install into a command that either finishes or fails loudly.
-
配置 unattended-upgrades,在 Debian 和 Ubuntu 上自动安装安全补丁
unattended-upgrades 通过定时器应用软件包更新,使用两个文件:20auto-upgrades(是否更新及频率)和 50unattended-upgrades(使用哪些来源及是否重启)。在生产环境启用之前用 --dry-run --debug 测试,可避免意外重启或只完成一半的升级。
机器可读: JSON