#!/bin/bash
#Linux服务器的初始化配置
#The author: liweizhong QQ:543302969 TEL:13751809209
#禁用暂时不使用的账号.
user=`cat /etc/passwd |awk -F":" ''{print $1,$7}''|grep -v nologin | grep bash | grep -v root | awk ''{print $1}''`
for i in $user
do
passwd -l $i
done
#限制记录命令历史的条数.超时自动注销.注销时清空命令历史记录.
dir=/etc/profile
sed -i "39s/1000/30/g" $dir
sed -i "40 iTMOUT=300" $dir
echo "history -c" >> ~/.bash_logout
#登录服务器时,显示相关信息.
#!/bin/bash
#登录服务器时,显示相关信息.
echo -e "33[31m "CPU核数:" `cat /proc/cpuinfo |grep processor | wc -l`"核" `vmstat |grep [0-9]|awk ''{print" 用户时间: " $13
"%" " 系统时间: " $14 "%" " CPU空闲时间: " $15"%" " I/O等待: " $16 "%"}''` 33[0m"
echo -e "33[31m `free -m |sed -n ''2p''|awk ''{print " 缓存: "$7"M"}''` 33[0m"|xargs echo -e "33[31m
`free -m |grep -v "buffers"|grep Mem|awk ''{print "内存使用:" " 总: "$2"M", " 已用:"$3"M", " 剩余:"$4"M"}''`33[0m"
echo -e "33[31m `uptime |awk ''{print "系统运行时间: " $3"小时" " 系统负载" " "$8 " "$9 " "$10}''` 33[0m"
"33[31m 进程总数: `ps aux |wc -l` 33[0m"
echo -e "33[31m "系统版本:" `cat /proc/version |awk ''{print $1,$3}''` 33[0m" "33[31m " 服务器名称:" `hostname` 33[0m"
"33[31m " 服务器IP:" `ifconfig eth0 | sed -n "2p" |awk ''{print $2}''| awk -F ":" ''{print $2}''` 33[0m"
echo -e "33[31m 磁盘使用: 33[0m"
echo -e "33[31m `df -lh |awk ''$6=="/" {print $0 }''|awk ''{print "目录:"$6 " 总:"$2 " 已用:"$3" 可用:"$4}'' ` 33[0m "
echo -e "33[31m `df -lh |awk ''$6=="/boot" {print $0 }''|awk ''{print "目录:"$6 " 总:"$2 " 已用:"$3" 可用:"$4}'' ` 33[0m "
echo -e "33[31m `df -lh |awk ''$6=="/opt" {print $0 }''|awk ''{print "目录:"$6 " 总:"$2 " 已用:"$3" 可用:"$4}'' ` 33[0m "
echo -e "33[31m `df -lh |awk ''$6=="/data" {print $0 }''|awk ''{print "目录:"$6 " 总:"$2 " 已用:"$3" 可用:"$4}'' ` 33[0m "
echo -e "33[31m `df -lh |awk ''$6=="/var" {print $0 }''|awk ''{print "目录:"$6 " 总:"$2 " 已用:"$3" 可用:"$4}'' ` 33[0m "
echo -e "33[31m `df -lh |awk ''$6=="/usr" {print $0 }''|awk ''{print "目录:"$6 " 总:"$2 " 已用:"$3" 可用:"$4}'
|