Write the background of this script: because more and more machines are being managed, each login machine can display the information of the corresponding machine to prevent mis-operation.
At the same time, the individual working environment has many springboard machines, but also easy to operate the error, so each machine added a login display.
Create a login display script
Modify
Vim/etc/profile
On the last line join
/usr/local/bin/login.sh
Put the script login.sh to/usr/local/bin
chmod 755/usr/local/bin/login.sh
The script content is as follows (only CENTOS6 and CENTOS7 test pass)
==================================
#!/bin/bash#server os infoos_version= ' if grep -q ' release 6 ' /etc/ redhat-release ; then os_version= ' CentOS6 ' else os_version= ' CentOS7 ' fiecho -e "##################### ########### #Server info################################################# "hostname= ' hostname ' ECHO -E "hostname = $hostname" osinfo= ' Cat /etc/redhat-release ' echo -e "os info = $osinfo" kernelinfo= ' uname -r ' echo -e "linuxkernel = $kernelinfo" kernelmac= ' uname -m ' echo -e "hw machine = $kernelmac" cpu= ' cat /proc/cpuinfo | grep " Model name " | head -n 1 | awk -F ": " " {print $2} "' Echo -e "CPu info = $CPU "if [ ${os_version} == ' CentOS6 ' ];then network= ' Ifconfig -a | awk ' begin {fs= ' \ n '; rs= ""} {print $1,$2} ' | grep -v ' lo ' | awk ' {print ' \t\t ' $1,$7} ' else network= ' ifconfig -a | awk ' begin {fs= "\ n"; rs= ""} {print $1,$2} ' | grep -v ' lo ' | awk ' {print ' \t\t ' $1,$6} ' fiecho -e ' Network info = \n$network "externalip=$ (timeout 3 curl -s ipecho.net/plain; echo) [ $? -ne 0 -o ' X ' == ' $externalip ' x ] && externalip= ' No outside network or acl drop ' echo -e "External IP = $externalip "ECho -e "--------------------------------------------------------------------------------------------- "Username= ' WhoAmI ' echo -e " username = $Username "echo -e "userhomedir = $HOME" echo -e "------------------------------------------------------ ---------------------------------------"
Log back in to the machine and display the following
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8E/DE/wKiom1jN5PqhyK_iAAFESC6Ta10559.jpg-wh_500x0-wm_ 3-wmp_4-s_2600331017.jpg "title=" login.jpg "alt=" Wkiom1jn5pqhyk_iaafesc6ta10559.jpg-wh_50 "/>
Displays the working directory of the current user when switching to another user
This article is from the "Go to the Origin dimension" blog, please make sure to keep this source http://yuanji6699.blog.51cto.com/11568362/1908044
Linux Shell Login Displays welcome or machine information