标签:虚拟机 初始优化 脚本
#!/bin/sh
##http://mirrors.aliyun.com/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum install tree -y
grep keepcache /etc/yum.conf
sed -i ‘s/keepcache=0/keepcache=1/g‘ /etc/yum.conf
grep keepcache /etc/yum.conf
#关闭selinux:
setenforce 0 #临时生效
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config #永久生效
setenforce 0
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config
##关闭防火墙
/etc/init.d/iptables stop
chkconfig iptables off
chkconfig --list iptables
#时间同步
/usr/sbin/ntpdate pool.ntp.org
echo ‘#time sync by lvnian at 2015-2-1‘>>/var/spool/cron/root
echo ‘*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1‘>>/var/spool/cron/root
crontab -l
#hostname
hostname $1
cp /etc/hosts /etc/hosts.bak
cp /etc/sysconfig/network /etc/sysconfig/network.bak
sed -i -e ‘/HOSTNAME=/d‘ -e "1aHOSTNAME=$1" /etc/sysconfig/network
本文出自 “技术改变命运” 博客,请务必保留此出处http://lvnian.blog.51cto.com/7155281/1697324
标签:虚拟机 初始优化 脚本
原文地址:http://lvnian.blog.51cto.com/7155281/1697324