每次新装CentOS后都要整一堆的基础配置信息,十分的不便,经整理成文档后,复制粘贴运行,工作变得轻松加愉快,工作效率直接翻倍。
1.安装国内更新源
#Centos7
yum install wget -y
cp -p /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak0
wget https://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum install epel-release -y
wget https://mirrors.aliyun.com/repo/epel-7.repo -O /etc/yum.repos.d/epel.repo
yum clean all
yum makecache
yum upgrade -y
#Centos8
yum install wget -y
cp -p /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak0
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum makecache
yum upgrade -y
2.安装工具类软件
yum install net-tools tree vim lrzsz rsync unzip bzip2 -y
3.配置VIM
vim ~/.vimrc
:set paste
set number
set ruler
set hls
4.禁用防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
iptables [centos6]
/etc/init.d/iptables status
/etc/init.d/iptables stop
selinux
vim /etc/selinux/config
disabled
#重启生效reboot
5.CENTOS7开机显示IP地址
cp /etc/issue /etc/issue_standard
vim /etc/init.d/show_ip.sh
#!/bin/bash
cp /etc/issue_standard /etc/issue
/usr/sbin/ip addr | grep "inet" |grep -v "inet6" | grep -v "127.0.0.1" | awk '{print $2}' >> /etc/issue
echo "" >> /etc/issue
修改脚本运行权限
chmod a+x /etc/init.d/show_ip.sh
配置脚本开机自启动
echo "/etc/init.d/show_ip.sh" >> /etc/rc.local
chmod a+x /etc/rc.local
重启生效reboot
6.修改主机名称
hostnamectl set-hostname Kickstart