如何自定义 Ubuntu 14.04.3 LTS 上的登录消息?
我想自定义以下登录消息。请告诉我需要编辑哪个文件。
[email protected]'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
答案1
要自定义登录前消息,例如创建登录横幅,您需要编辑/etc/issue
文件。
要定制登录后消息,您可以编辑 中的某些文件。该目录中的和/etc/update-motd.d
等文件可以安全编辑。00-header
10-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
}
我在末尾用 调用了该函数。从.bashrc
代码testTTY
中你可以看到,该函数确定我是否登录到 TTY,如果是 TTY,它会显示适当的消息和df
命令输出
答案2
配置文件位于/etc/update-motd.d
。motd
代表每日讯息。