Shell startup information

write shell script

sys_hostname=`hostname`
sys_ip_addrs=`hostname -I`
sys_mem_total=`free -h |awk 'NR==2{print $2}'`
sys_mem_free=`free -h |awk 'NR==2{print $NF}'`
sys_load=`uptime |awk '{print $(NF-2),$(NF-1),$NF}'`

cat<<EOF
     主机名:   ${sys_hostname}
     ip地址:   ${sys_ip_addrs}
     总内存:   ${sys_mem_total}
     可用内存: ${sys_mem_free}
     系统负载: ${sys_load}
EOF

Move the file to System Files

cp 01-demo.sh /etc/profile.d/show-info.sh

Guess you like

Origin blog.csdn.net/m0_46213587/article/details/127248651