#!/bin/bash
#配置网络
cd /etc/sysconfig/network-scripts/
sed -i '/^BOOT/c BOOTPROTO=static' ifcfg-ens33
sed -i '/ONBOOT/c ONBOOT=yes' ifcfg-ens33
read -p "设置IP:" IP
cat <<EOF >> ifcfg-ens33
IPADDR=$IP
PREFIX=16
DNS1=211.137.32.178
GATEWAY=172.16.0.244
EOF
systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl restart network
ping -c3 www.baidu.com &> /dev/null && echo "网络配置完成!"
sleep 2
#配置主机名、用户名显示为绿色、路径为绝对路径且是红色
read -p "设置主机名:" hostanme
hostnamectl set-hostname $hostname
echo 'export PS1="[\u@\[\e[35;40m\]\h \[\e[31;40m\]\w\[\e[0m\]]\\$ "' >> /etc/profile
source /etc/profile
echo "主机名配置完成!"
sleep 2
#关闭防火墙
iptables -F
systemctl stop firewalld
systemctl disable firewalld
echo "关闭防火墙!"
sleep 2
#禁用selinux
sed -i "/SELINUX/s/enforcing/disabled/" /etc/selinux/config
echo "禁用selinux"
#安装epel
源、安装常用的软件
cd /etc/yum.repos.d/
gzip *
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum list
yum install -y unzip 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 "同步时间!"
#处理有的时候ssh
登陆缓慢
vim /etc/ssh/sshd_config
UseDNS no
GSSAPIAuthentication no
#清空/var/log/btmp
> /var/log/btmp
#重启
echo "重启机器"
sleep 2
init 6
centos7
显示中文
(1)先检测是否安装了中文包
locale -a
如果没有,则安装
yum install kde-l10n-Chinese
(2)查看当前语言
locale
如果不是中文、则更改i18n
国际化和locale.conf
本土化配置文件(更改到如下图所示)
vim /etc/locale.conf
LANG=zh_CN.utf8
vim /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
LC_ALL="zh_CN.UTF-8"
然后重启
reboot
最后在操作系统图形化界面也设置一下区域和语言就ok
了