/ etc / motd如何更新?

我想知道/ etc / motd是如何自动更新的(我在Ubuntu 10.04,服务器版)。 我通过网络搜索找到了update-motd联机帮助页,但该程序未安装在我的计算机上。 但是,/ etc / motd文件会定期更新。 我只是不知道如何以及如何经常。 在执行locate motd ,会列出以下文件:

 /etc/motd /etc/update-motd.d /etc/update-motd.d/00-header /etc/update-motd.d/10-help-text /etc/update-motd.d/20-cpu-checker /etc/update-motd.d/50-landscape-sysinfo /etc/update-motd.d/90-updates-available /etc/update-motd.d/91-release-upgrade /etc/update-motd.d/98-reboot-required /etc/update-motd.d/99-footer /home/me/.cache/motd.legal-displayed /lib/security/pam_motd.so /usr/bin/motd+shell /usr/lib/update-manager/release-upgrade-motd /usr/lib/update-notifier/update-motd-cpu-checker /usr/lib/update-notifier/update-motd-reboot-required /usr/lib/update-notifier/update-motd-updates-available /usr/share/base-files/motd.md5sums /usr/share/man/man1/motd+shell.1.gz /usr/share/man/man5/motd.5.gz /usr/share/man/man5/motd.tail.5.gz /usr/share/man/man5/update-motd.5.gz /usr/share/man/man8/pam_motd.8.gz /usr/share/ubuntu-serverguide/html/C/pam_motd.html 

它在登录时由pam_motd更新。 update-motd手册页描述了这个:

  Ubuntu introduced the update-motd framework, by which the motd(5) is dynamically assembled from a collection of scripts at login. Executable scripts in /etc/update-motd.d/* are executed by pam_motd(8) as the root user at each login, and this information is concatenated in /var/run/motd. The order of script execution is determined by the run- parts(8) --lsbsysinit option (basically alphabetical order, with a few caveats). On Ubuntu systems, /etc/motd is typically a symbolic link to /var/run/motd. 

上面接受的答案是正确的,但不完整。 我希望这为OP提供更多信息。

基本上,在全新安装时,motd来自三个地方:

  1. /etc/update-motd.d/中的脚本
  2. 由/etc/pam.d/login控制的已编译二进制文件
  3. / etc / legal文件

3号指的是你的motd末尾的文本块,其中包括“Ubuntu绝对没有保证…”,这是/ etc / legal文件。 但是,您在/etc/update-motd.d/下找不到任何提及它的内容,“/ legal”一词也不会出现在/etc/pam.d/login文件中的任何位置。 它的包含已经变得模糊不清,我真的不知道它是如何进入那里的。 我的意思是我知道有一个{$ HOME} /.cache / motd.legal-显示但我不知道它们来自哪里(还)。

pam.d / login文件负责通知待处理的电子邮件,但这并不模糊。 有一个很好的评论描述“在成功登录时打印用户邮箱的状态”就在文件中。 我认为从技术上来说,这不是真正的一部分,但它会在登录时出现,如果你是新手,那么精细的区别可能不会被欣赏。

在全新安装14.04时, 没有 / etc / motd文件。 如果您创建一个(或创建motd.static和符号链接到motd),该文件的内容将附加到update-motd.d脚本生成的文本,但/ etc / legal的内容将停止显示。 去搞清楚。 电子邮件通知仍然出现,所以这不会中断pam.d /登录脚本,所以我怀疑/ etc / legal是从那里拉入的。 它的采购对读者来说仍然是一个谜。 我注意到当我删除/ etc / motd链接(或文件)时,法律免责声明不会立即回来。 这需要几分钟。 我不想经常看到免责声明,所以我删除了该文件中的文本。

干杯。

为了扩展David Kuhl的回答:

全新安装的Ubuntu Server 14.04.1 LTS显然不会安装landscape-common和update-notifier-common软件包。 因此,未安装以下脚本:

 /etc/update-motd.d/50-landscape-sysinfo /etc/update-motd.d/90-updates-available 

因此,要从12.04 LTS迁移的服务器获取所有ssh登录信息,必须手动安装上述软件包:

 sudo apt-get install landscape-common update-notifier-common