以下是 /etc/default/motd-news 文件的内容:
| $ cat /etc/default/motd-news # Enable/disable the dynamic MOTD news service # This is a useful way to provide dynamic, informative # information pertinent to the users and administrators # of the local system ENABLED=1 # Configure the source of dynamic MOTD news # White space separated list of 0 to many news services # For security reasons, these must be https # and have a valid certificate # Canonical runs a service at motd.ubuntu.com, and you # can easily run one too URLS="https://motd.ubuntu.com" # Specify the time in seconds, you're willing to wait for # dynamic MOTD news # Note that news messages are fetched in the background by # a systemd timer, so this should never block boot or login WAIT=5 |
好事情是 MOTD 是完全可定制的,所以你可以彻底禁用它(ENABLED=0)、根据你的意愿更改或添加脚本、以秒为单位更改等待时间等等。
如果启用了 MOTD,那么 systemd 计时器作业将循环遍历每个 URL,将它们的内容缩减到每行 80 个字符、最多 10 行,并将它们连接到 /var/cache/motd-news 中的缓存文件。此 systemd 计时器作业将每隔 12 小时运行并更新 /var/cache/motd-news。用户登录后,/var/cache/motd-news 的内容会打印到屏幕上。这就是 MOTD 的工作原理。
此外,/etc/update-motd.d/50-motd-news 文件中包含自定义的用户代理字符串,以报告有关计算机的信息。如果你查看 /etc/update-motd.d/50-motd-news 文件,你会看到:
| # Piece together the user agent USER_AGENT="curl/$curl_ver $lsb $platform $cpu $uptime" |
这意味着,MOTD 检索器将向 Canonical 报告你的操作系统版本、硬件平台、CPU 类型和正常运行时间。
到这里,希望你对 MOTD 有了一个基本的了解。
现在让我们回到主题,我不想要这个功能。我该如何禁用它?如果欢迎消息中的促销链接仍然困扰你,并且你想永久禁用它们,则可以通过以下方法快速禁用它。
在 Ubuntu 服务器中禁用终端欢迎消息中的广告
要禁用这些广告,编辑文件:
| $ sudo vi /etc/default/motd-news |
找到以下行并将其值设置为 0(零)。
| [...] ENABLED=0 [...] |
保存并关闭文件。现在,重新启动系统,看看欢迎消息是否仍然显示来自 Ubuntu 博客的链接。

看到没?现在没有来自 Ubuntu 博客和 Ubuntu wiki 的链接。
总结
以上所述是小编给大家介绍的怎么禁用 Ubuntu 服务器中终端欢迎消息中的广告,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对易采站长站网站的支持!








