如何在Ubuntu 14.04.3 LTS上自定义登录消息

如何在Ubuntu 14.04.3 LTS上自定义登录消息?

我想自定义以下登录信息。请让我知道我需要编辑哪个文件。

root@10.1.235.227's password: Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-25-generic x86_64) * Documentation: https://help.ubuntu.com/ System information as of Wed Oct 14 01:05:33 CDT 2015 System load: 0.0 Processes: 117 Usage of /home: 0.1% of 944MB Users logged in: 1 Memory usage: 4% IP address for eth0: 10.1.235.227 Swap usage: 0% Graph this data and manage this system at: https://landscape.canonical.com/ 0 packages can be updated. 0 updates are security updates. Last login: Wed Oct 14 01:05:35 2015 from 172.20.20.98 

要自定义登录前消息,例如创建登录标题,您需要编辑/etc/issue文件。

要自定义登录后消息,可以编辑/etc/update-motd.d某些文件。 可以安全地编辑该目录中的00-header10-help-text文件。

另一种可能性是在文件末尾的.bashrc中添加自定义函数/命令。

例如,我在.mkshrc文件的顶部定义了以下函数:

  testTTY(){ isTTY=$(tty | awk '{if ($0~/\/dev\/tty.*/) {print "true"}else{print "false"}}') if [ "$isTTY" = "true" ]; then printf "You are in virtual console\n" printf "current disk usage is" df fi } 

我只用testTTY调用.bashrc末尾的函数。 从代码中可以看出,该函数确定我是否登录到TTY,如果是TTY,则显示相应的消息并输出df命令

配置文件位于/etc/update-motd.dmotd代表当天信息