为centos 7.2 用于其他系统需要更改位置变量
[root@didichuxing detection_script]# cat loginuser.sh
#!/bin/bash
cat << EOF > /etc/motd
Welcome
EOF
if [ -e /detection_script ]
then
mkdir -p /detection_script/
else
mkdir -p /detection_script/
fi
LoginUser=uptime |awk '{print $(NF-6)}'
w=w | awk 'NR>2{print "登录时间:" $4 "\t" "登录用户:"$1}'
i=whoami
nczs=free -m |grep "Mem" | awk '{print $2}'
cpuzs=grep "model name" /proc/cpuinfo | cut -f2 -d:
wlzs=grep 'physical id' /proc/cpuinfo | sort -u | wc -l
hxsl=grep 'core id' /proc/cpuinfo | sort -u | wc -l
xtbb=more /etc/redhat-release
nhbb=uname -r
xtkj=getconf LONG_BIT
Ip=ip a | grep inet | grep -v inet6 | grep -v 127 | sed 's/^[ \t]*//g' | cut -d ' ' -f2
if [ $LoginUser -ge 1 ]
then
echo "==========================================="
echo "系统登录人数为: $LoginUser人"
echo "$w"
echo "==========================================="
echo "系统内存总数为: $nczs M"
echo "==========================================="
echo "物理CPU个数: $wlzs个,核心CPU个数: $hxsl个"
echo "$cpuzs"
echo "==========================================="
echo "系统版本: $xtbb"
echo "内核版本: $nhbb"
echo "系统架构: x$xtkj位"
echo "物理地址: $Ip"
echo "==========================================="
echo "您是管理员$i用户,拥有最大权限,请谨慎操作!"
echo ""
fi
/bin/mv loginuser.sh /detection_script/
chmod a+x loginuser.sh
vim .bash_profile
在最后一行添加
/detection_script/loginuser.sh
转载于:https://blog.51cto.com/amunlinux/2104368