centos7配好后都丢在一边不管,而过些日子想再维护的话它的,机器多分不出哪台对哪台。只能再接显示器与键盘查看。为了方便管理以及标识出它是哪台机,我需要在它登录前就显示它的ip,方法如下:
先备份
cp /etc/issue /etc/issue_standard
创建脚本 /etc/init.d/show_ip.sh
vim /etc/init.d/show_ip.sh
输入以下内容
#!/bin/bash cp /etc/issue_standard /etc/issue /usr/sbin/ip addr | grep "inet" |grep -v "inet6" | grep -v "127.0.0.1" | awk '{print $2}' >> /etc/issue echo "" >> /etc/issue
配置脚本开机自启动。
echo "/etc/init.d/show_ip.sh" >> /etc/rc.local chmod a+x /etc/init.d/show_ip.sh chmod a+x /etc/rc.local
效果如下: