CentOS基础配置
:IT学习乐园
:Builder
:20230202
:78

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

创建脚本 /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元起,免费云解析,一站式建站,买3年...

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

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

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

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

立刻前往...
企业上云钜惠
企业上云钜惠

多款刚需产品,满足企业通用场景需求,云服务器2.5折起...

立刻前往...