Centos7初始化

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值