最近,每当我运行时apt update/upgrade
,我都会在终端中收到以下消息:
Try Ubuntu Pro beta with a free personal subscription on up to 5 machines.
Learn more at https://ubuntu.com/pro
有人知道有什么办法可以摆脱这个问题吗?
答案1
一个选项是创建 20apt-esm-hook.conf 到 /dev/null 的符号链接:
sudo ln -s -f /dev/null /etc/apt/apt.conf.d/20apt-esm-hook.conf
另一个选择是仅注释掉该文件中的操作行:
sudo sed -i'' -e 's/^\(\s\+\)\([^#]\)/\1# \2/' /etc/apt/apt.conf.d/20apt-esm-hook.conf
或者第三种选择是将该文件重命名为 .bak 文件,并创建一个同名的零长度文件:
sudo mv /etc/apt/apt.conf.d/20apt-esm-hook.conf /etc/apt/apt.conf.d/20apt-esm-hook.conf.bak
sudo touch /etc/apt/apt.conf.d/20apt-esm-hook.conf
答案2
恰当的广告是选择退出,而 Canonical 官方的做法则有点神秘。禁用此功能的界面是:
sudo pro config set apt_news=false
答案3
删除每日消息文件并禁用 Ubuntu Advantage:
sudo rm /etc/update-motd.d/88-esm-announce
sudo systemctl disable ubuntu-advantage
答案4
strace
说它来自这里:
33812 openat(AT_FDCWD, "/var/lib/ubuntu-advantage/messages/apt-pre-invoke-no-packages-apps.tmpl", O_RDONLY) = 3
33812 read(3, "Try Ubuntu Pro beta with a free "..., 8191) = 111
所以:
sudo rm /var/lib/ubuntu-advantage/messages/*.tmpl