CentOS基础配置
:IT学习乐园
:Builder
:20241008
:987

每次新装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






华为云速邮箱
华为云速邮箱

企业办公必备, 安全简单易用收发稳定的企业邮箱...限时...

立刻前往...
华为企业应用专场
华为企业应用专场

企业建站买1年送2年,商标注册270元起,企业邮箱400...

立刻前往...
阿里新人特惠专享
阿里新人特惠专享

新用户首购1元起,精选云服务器ECS 1核2G n4 9...

立刻前往...
腾讯云限时秒杀
腾讯云限时秒杀

热门云产品首单特惠秒杀,1核2G云服务器首年38元。...

立刻前往...