在 Debian 系统中,所谓的“广告消息”通常来自 Debian 的官方公告、软件包提示、MOTD(当日消息)或第三方软件。下面按常见来源给你一套安全、可逐步操作的屏蔽方案。
Debian 12+ 会在 apt update 后显示类似:
“Debian has a new release / Please consider donating”
关闭方法:
sudo apt remove -y debian-system-adjustments 2>/dev/null
sudo apt remove -y popularity-contest
并编辑:
sudo nano /etc/apt/apt.conf.d/99no-advert
加入:
APT::Get::Show-User-Simulation-Note "false";
APT::Get::Update::Show-Release-Notes "false";
登录时看到的 Debian 新闻来自 /etc/motd 或 pam_motd。
ls -l /etc/update-motd.d/
sudo chmod -x /etc/update-motd.d/*
或完全禁用:
sudo systemctl disable motd-news.timer
sudo systemctl stop motd-news.timer
sudo systemctl mask motd-news.service
sudo systemctl disable motd-news.service
Debian 会提示是否参与“流行度调查”。
sudo apt purge popularity-contest
并确认:
dpkg-reconfigure popularity-contest
选择 No
sudo apt purge snapd
或屏蔽 snap 商店提示:
sudo rm -rf /etc/update-motd.d/*snap*
创建配置文件:
sudo nano /etc/apt/apt.conf.d/99quiet
内容:
APT::Periodic::Enable "0";
APT::Get::Show-Upgraded "false";
APT::Get::Show-User-Simulation-Note "false";
DPkg::Progress-Fancy "0";
grep -R "debian.org" /etc/apt /etc/cron* /etc/profile.d /etc/update-motd.d
sudo apt purge popularity-contest
sudo chmod -x /etc/update-motd.d/*
sudo systemctl disable motd-news.timer
如果你愿意,可以告诉我:
我可以给你 精确到文件级别 的定制方案。