#!/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