Ubuntu 26禁用自动升级
原创
沈沉舟
沈沉舟
青衣十三楼飞花堂
2026年6月18日 00:00
北京
在小说阅读器读本章
去阅读
☆ Ubuntu 26禁用自动升级
vi defer_snap_update_1.sh
#!/bin/bash
systemctl stop snapd
jq -c \".data[\\\"last-refresh\\\"] = \\\"$(date +%Y-%m-%dT%H:%M:%S.%N%:z)\\\"\" /var/lib/snapd/state.json > /tmp/state.json
mv /tmp/state.json /var/lib/snapd/state.json
chmod 600 /var/lib/snapd/state.json
systemctl start snapd
snap set system refresh.timer=fri5,14:00-14:05
snap set system refresh.hold=\"$(date --iso-8601=seconds -d 'today+100 days')\"
snap set system refresh.metered=hold
snap set system refresh.retain=2
snap set core experimental.refresh-app-awareness=true
snap refresh --time
以root身份定期执行defer\_snap\_update\_1.sh,间隔不要大于3个月,以此阻止snap升级。
Ubuntu 26缺省没有\"Software & Updates\",据说可以装回来
apt install software-properties-gtk
但我不想装回来。下面是一种过度防御方案,确保阻止apt自动升级,同时不影响手动升级。
systemctl mask --now unattended-upgrades
systemctl status unattended-upgrades
\"mask --now\"已含stop、disable的效果
# systemctl list-timers | grep apt
apt-daily.timer apt-daily.service
apt-daily-upgrade.timer apt-daily-upgrade.service
虽然有四项,但它们是两组,timer是触发器,service是真正干活的。
systemctl mask --now apt-daily.timer
systemctl mask --now apt-daily.service
systemctl mask --now apt-daily-upgrade.timer
systemctl mask --now apt-daily-upgrade.service
systemctl status apt-daily.timer
systemctl status apt-daily.service
systemctl status apt-daily-upgrade.timer
systemctl status apt-daily-upgrade.service
vi /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists \"0\";
APT::Periodic::Download-Upgradeable-Packages \"0\";
APT::Periodic::Unattended-Upgrade \"0\";
apt-config dump | grep -i periodic
再加一道保险
Settings
Network
Wired
Details
Metered connection: has data limits or can incur charges
On (Software updates and other large downloads will not be started automatically)
版权声明
本站仅做备份收录,仅供研究与教学参考之用。
读者将信息用于其他用途的,全部法律及连带责任由读者自行承担,本站不承担任何责任。











评论