linux-centos6/7初始配置

关闭防火墙

chkconfig iptables off
centos7下的命令为
systemctl stop firewalld.service  #停止Firewall
systemctl disable firewalld.service  #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态

关闭selinux

vi /etc/selinux/config
SELINUX=disabled

临时关闭selinux:setenforce 0

重启生效

查看命令如下:
getenforce
/usr/sbin/sestatus -v

网卡开机启动(dhcp)

vi /etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes

如果是静态IP地址,则配置如下:

TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.1.101
NETMASK=255.255.255.0
NETWORK=192.168.1.0
NAME=enp0s3
DEVICE=enp0s3
ONBOOT=yes
DNS1=114.114.114.114

修改主机名

vim /etc/sysconfig/network
HOSTNAME=CentOS

安装iostat,wget

yum install -y wget
yum install -y sysstat

修改yum源为ali

cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bk
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm 
rpm -ivh epel-release-latest-6.noarch.rpm
yum clean all
yum makecache
yum install -y yum-fastestmirror

centos7下可以执行

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

以下为163、科大、sohu的源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo  http://centos.ustc.edu.cn/CentOS-Base.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo  http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
原文地址:https://www.cnblogs.com/tcicy/p/8298341.html