#!/bin/bash
#配置网络
cd /etc/sysconfig/network-scripts/
read -p "设置IP:" IP
cat <<EOF > ifcfg-eth0
ONBOOT=yes
NM_CONTROLLED=no
IPADDR=$IP
NETMASK=255.255.0.0
DEVICE=eth0
BOOTPROTO=static
DNS1=8.8.8.8
GATEWAY=172.16.0.244
EOF
/etc/init.d/NetworkManager stop
/etc/init.d/NetworkManager status
chkconfig NetworkManager off
chkconfig --list NetworkManager
#systemctl disable NetworkManager
service network restart
rm -f /etc/udev/rules.d/70-persistent-net.rules
ping -c3 www.baidu.com &> /dev/null && echo "网络配置完成!"
sleep 2
#配置主机名、用户名显示为绿色、路径为绝对路径且是红色
echo "HOSTNAME=haha" > /etc/sysconfig/network
echo 'export PS1="[\u@\[\e[32;40m\]\h \[\e[31;40m\]\w\[\e[0m\]]\\$ "' >> /etc/profile
source /etc/profile
echo "主机名配置完成!"
sleep 2
#关闭防火墙
iptables -F
/etc/init.d/iptables stop
chkconfig iptables off
/etc/init.d/iptables status
chkconfig --list iptables
echo "关闭防火墙!"
sleep 2
#禁用selinux
sed -i "/SELINUX/s/enforcing/disabled/" /etc/selinux/config
echo "禁用selinux"
#配置网络yum
源
cd /etc/yum.repos.d/
gzip *
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
sed -i 's/$releasever/6/g' /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum list
#安装epel
源、安装常用的软件
yum install -y vim-enhanced gpm openssh-clients man-pages bash-completion net-tools wget ftp lftp ntp ntpdate setuptool authconfig ntsysv acpid gcc gcc-c++ make createrepo lrzsz
echo "安装epel源、安装常用软件!"
sleep 2
#同步时间
echo "ntpdate ntp1.aliyun.com" >> /etc/rc.local
chmod +x /etc/rc.d/rc.local
source /etc/rc.d/rc.local
echo "同步时间!"
echo "初始化完成,模板机即将关闭!"
#关机
sleep 3
reboot
CentOS6
支持中文
1.查看系统是否安装有中文语言包
locale -a | grep "zh_CN"
命令含义:列出所有可用的公共语言环境的名称,包含有"zh_CN
"
2.如果没有安装中文语言包,那么安装一下中文语言包
yum groupinstall "fonts"
(或者 yum install kde-l10n-Chinese
)
3.查看当前语言
locale
修改# /etc/sysconfig/i18n
LANG="en_US.UTF-8" 改为LANG="zh_CN.UTF-8"