Ubuntu禁止自动更新

1. 编辑自动更新文件

文件位置: /etc/apt/apt.conf.d/20auto-upgrades

将内容中所有值为 1 的都改成 0 后保存退出, 编辑文件需要sudo权限

APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Unattended-Upgrade "0";

反向操作: 改回原来的值并保存退出

2. 卸载无人值守自动更新软件
sudo apt purge --auto-remove unattended-upgrades

反向操作: sudo apt install unattended-upgrades

3. 停止系统自动更新定时器
sudo systemctl disable apt-daily-upgrade.timer
sudo systemctl mask apt-daily-upgrade.service
sudo systemctl disable apt-daily.timer
sudo systemctl mask apt-daily.service

反向操作:

sudo systemctl enable apt-daily-upgrade.timer
sudo systemctl unmask apt-daily-upgrade.service
sudo systemctl enable apt-daily.timer
sudo systemctl unmask apt-daily.service
禁止snap自动更新的三种方式

方式一: 如果不经常用到snap工具安装软件, 可以直接卸载掉

sudo apt purge --auto-remove snapd

反向操作: sudo apt install snapd
方式二: 停止snap的后台服务进程

sudo systemctl stop snapd.service
sudo systemctl stop snapd.socket
sudo systemctl mask snapd.service
sudo systemctl mask snapd.socket

反向操作:

sudo systemctl unmask snapd.service
sudo systemctl unmask snapd.socket
sudo systemctl start snapd.service
sudo snap refresh

方式三: 禁止snap程序连接服务器

sudo echo "127.0.0.1 api.snapcraft.io" >> /etc/hosts

反向操作: 在 /etc/hosts 文件中删掉该行

你可能感兴趣的:(各种问题,ubuntu,服务器,linux)