登录终端时,显示自定义文本

登录终端时,显示自定义文本

当我通过 PuTTY 登录 Linux 系统时,我收到以下文本。欢迎来到

Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic i686)

 * Documentation:  https://help.ubuntu.com/

  System information as of Tue Jan 27 08:58:36 IST 2015

  System load:  0.0               Processes:           109
  Usage of /:   2.3% of 71.00GB   Users logged in:     0
  Memory usage: 9%                IP address for eth0: 192.168.5.135
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

55 packages can be updated.
0 updates are security updates.

*** System restart required ***
Last login: Tue Jan 27 08:58:40 2015 from 192.168.5.102

它显示操作系统名称、系统负载、内存信息、编号。更新、正常运行时间等。我还想显示更多内容,如下所示。

Bluetooth is ON. Address: 00:AA:08:34:54
USB is conneted. Mount point '/mnt/mydrive/'
Mysql service is running

我知道我们可以编写这些脚本来~/.bashrc显示上述信息。但我不喜欢在那里添加。我还想在上面显示我的自定义文本*** System restart required ***。所以我想知道系统如何打印这些信息。谢谢。

答案1

Ubuntu 的 motd 是通过运行/etc/update-motd.d/.

在我的 14.04 系统上,该*** System restart required ***消息似乎是由 script 生成的98-reboot-required,因此要添加自定义消息,您应该创建一个数字小于 98 的脚本,并让它运行命令或回显您想要的任何消息。不要忘记使新脚本可执行。

参考:http://www.howtogeek.com/104708/how-to-customize-ubuntus-message-of-the-day/

相关内容