Linux主機平常維護

#!/bin/bashbash


####關閉沒必要要的TTY  ps aux|grep ttycookie

cp /etc/init/start-ttys.conf /etc/init/start-ttys.conf.bakssh

echo "cp /etc/init/start-ttys.conf /etc/init/start-ttys.conf.bk"tcp

sed -i "s/tty\[1-6\]/tty\[1-2\]/" /etc/init/start-ttys.confide

cp /etc/sysconfig/init /etc/sysconfig/init.bakspa

echo "cp /etc/sysconfig/init /etc/sysconfig/init.bk"ip

####內核調優it

cp /etc/sysctl.conf /etc/sysctl.conf.bkio

#echo "net.ipv4.tcp_syncookies = 1" >> /etc/sysctl.confcookies

echo "net.ipv4.tcp_tw_reuse = 1" >> /etc/sysctl.conf

echo "net.ipv4.tcp_tw_recycle = 1" >> /etc/sysctl.conf

sysctl -p

####最大文件打開數

cp /etc/security/limits.conf /etc/security/limits.conf.bk

echo "* soft nofile 65536" >> /etc/security/limits.conf

echo "* hard nofile 65536" >> /etc/security/limits.conf

####開機啓動網卡

for eth in `ls /etc/sysconfig/network-scripts/ifcfg-eth*`; 

do

sed -i "s/ONBOOT=no/ONBOOT=yes/" $eth

done

####關閉寫磁盤I/O

#vi /etc/fstab

#/dev/sad /data ext4 noatiome,nodiratime 0 0


####關閉SSH空密碼 DNS反向解析

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bk

echo "cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bk"

sed -i "s/#PermitEmptyPasswords no/PermitEmptyPasswords no/" /etc/ssh/sshd_config

sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config

####

相關文章
相關標籤/搜索