Ubuntu 24.04 彻底关闭自动更新(桌面+服务器通用)
分三种方案:图形界面快速关闭(桌面)、命令行标准关闭(推荐)、彻底锁死所有自动更新(生产服务器)
一、图形界面关闭(Desktop 桌面版)
- 打开「软件和更新」
gnome-control-center software- 切换到Updates标签页
- 修改下拉选项:
- Automatically check for updates:Never
- When there are security updates:Display immediately(不自动下载安装)
- When there are other updates:Display weekly
- Notify me of a new Ubuntu version:Never
- 关闭窗口,设置立即生效
二、命令行标准关闭(通用,桌面/服务器)
1. 交互式关闭无人值守自动升级
sudodpkg-reconfigure-plowunattended-upgrades弹出选项选No回车,自动修改配置文件。
2. 手动修改自动更新配置
sudonano/etc/apt/apt.conf.d/20auto-upgrades全部改为 0(0=关闭,1=开启):
APT::Periodic::Update-Package-Lists "0"; APT::Periodic::Unattended-Upgrade "0";保存:Ctrl+O→ 回车 →Ctrl+X
3. 停止并禁用自动更新服务
# 停止无人值守升级sudosystemctl stop--nowunattended-upgradessudosystemctl disable unattended-upgrades# 关闭每日apt检查定时任务(核心后台自动检查)sudosystemctl stop--nowapt-daily.timer apt-daily-upgrade.timersudosystemctl disable apt-daily.timer apt-daily-upgrade.timer三、彻底锁死(生产服务器,完全杜绝后台更新)
在上面基础上,屏蔽服务+禁用固件自动更新+关闭更新弹窗
# 屏蔽apt定时与自动升级服务(无法自启)sudosystemctl mask unattended-upgrades apt-daily.service apt-daily-upgrade.service apt-daily.timer apt-daily-upgrade.timer# 关闭固件自动更新fwupdsudosystemctl mask fwupd fwupd-refresh.timer fwupd-offline-update# 关闭桌面右上角更新提示(桌面版执行)sudomv/etc/xdg/autostart/update-notifier.desktop /etc/xdg/autostart/update-notifier.desktop.bak四、关闭 Snap 自动更新(弹窗频繁更新snap)
Ubuntu24.04 默认Firefox为snap,会后台自动更新:
# 禁止snap自动刷新sudosnapsetsystemrefresh.timer=00:00,00:00# 查看snap刷新状态snap get system refresh五、恢复自动更新(需要时)
# 解除屏蔽sudosystemctl unmask unattended-upgrades apt-daily.service apt-daily-upgrade.service apt-daily.timer apt-daily-upgrade.timer fwupd fwupd-refresh.timer fwupd-offline-update# 启用定时任务sudosystemctlenable--nowapt-daily.timer apt-daily-upgrade.timer unattended-upgrades# 恢复配置sudodpkg-reconfigure-plowunattended-upgrades# 选Yes# 恢复snap更新sudosnapsetsystemrefresh.timer=00:00~24:00重要提醒
关闭自动更新后不会自动安装安全补丁,建议定期手动执行更新:
sudoaptupdate&&sudoaptupgrade-y