温馨提示×

如何屏蔽Debian广告消息

小樊
45
2026-07-12 13:40:51
栏目: 智能运维

Debian 系统中,所谓的“广告消息”通常来自 Debian 的官方公告、软件包提示、MOTD(当日消息)或第三方软件。下面按常见来源给你一套安全、可逐步操作的屏蔽方案


一、屏蔽 Debian 官方公告(APT 消息)

1️⃣ 关闭 APT 的“欢迎/广告”提示

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";

二、关闭 MOTD(登录时的广告/公告)

2️⃣ 禁用 MOTD 消息

登录时看到的 Debian 新闻来自 /etc/motdpam_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

三、屏蔽 Debian 安全/新闻推送(systemd)

3️⃣ 关闭 systemd 的 Debian 新闻

sudo systemctl mask motd-news.service
sudo systemctl disable motd-news.service

四、关闭 popularity-contest(统计/广告)

Debian 会提示是否参与“流行度调查”。

sudo apt purge popularity-contest

并确认:

dpkg-reconfigure popularity-contest

选择 No


五、屏蔽第三方软件广告(如 snap / chrome)

5️⃣ Snap 广告(如果你装了 snap)

sudo apt purge snapd

或屏蔽 snap 商店提示:

sudo rm -rf /etc/update-motd.d/*snap*

六、彻底关闭所有 APT 附加消息(推荐)

创建配置文件:

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

✅ 总结(最常用 3 步)

sudo apt purge popularity-contest
sudo chmod -x /etc/update-motd.d/*
sudo systemctl disable motd-news.timer

如果你愿意,可以告诉我:

  • Debian 版本(11 / 12 / Testing)
  • SSH 登录提示apt update 弹窗 还是 桌面通知
  • 是否使用 GNOME / KDE

我可以给你 精确到文件级别 的定制方案。

0