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


17

如何在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

Answers:


20

要自定义登录前消息,例如创建登录横幅,您需要编辑/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
}

我调用函数在结束.bashrctestTTY。从代码中可以看到,该函数确定我是否登录到TTY,如果是TTY,它将显示适当的消息和df命令输出


5

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


您好,我想从登录提示中删除这些行并做出我自己的自定义消息
Nidhi 2015年

尝试更改文件,看看会发生什么。例如,在00-header文件末尾添加一行'printf“ My custom message”'。看一下printf行,并根据需要更改它们。
没人2015年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.