Linux的服务器初始优化脚本。

#!/bin/bash
#优化服务器启动的脚本、禁用无关账号、无关服务
#Lock User Account
passwd -l xfs
passwd -l news
passwd -l nscd
passwd -l dbus
passwd -l vcsa
passwd -l games
passwd -l nobody
passwd -l avahi
passwd -l haldaemon
passwd -l gopher
passwd -l ftp
passwd -l mailnull
passwd -l pcap
passwd -l mail
passwd -l shutdown
passwd -l halt
passwd -l uucp
passwd -l operator
passwd -l sync
passwd -l adm
passwd -l lp
#Language Set 中文设置
sed -i -e 's/^LANG=.*/LANG="zh_CN.UTF-8"/' /etc/sysconfig/i18n
source /etc/sysconfig/i18n
#Init Mode 无桌面模式启动
sed -i -e 's/^id.*initdefault.*$/id:3:initdefault:/' /etc/inittab
#sshd 提高速度
sed -i "s/#MaxAuthTries 6/MaxAuthTries 6/" /etc/ssh/sshd_config
sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
#Service Set...Stop all except ssh and network 把除了ssh 和网络服务全禁用了
server=`chkconfig --list | awk '{print $1}' | grep -E -v 'sshd|network'`
for i in $server
do
service $i stop
chkconfig --level 35 $i off
done
#Start and Set autostart
server2=`chkconfig --list | awk '{print $1}' |grep -E 'network|sshd|cpuspeed|syslog|crond|iptables|lvm2-monitor'`
for i in $server2
do
service $i start
chkconfig --level 35 $i on
done
init 3
#Vim Settings
sed -i -e 's/^.*fileencodings=.*/set fileencodings=cp936,utf-8,latin1/' /etc/vimrc
\cp /etc/vimrc ~/.vimrc
echo 'set nowrap' >> /root/.vimrc
echo 'set autochdir' >> /root/.vimrc
echo 'set paste' >> /root/.vimrc
echo 'colo desert' >> /root/.vimrc
echo 'set nu' >> /root/.vimrc

 

posted on 2013-09-22 23:11  DieAngel  阅读(442)  评论(0编辑  收藏  举报

导航