CentOS基础配置
:IT学习乐园
:Builder
:20241121
:1K+

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






注册认证上云抽好礼
注册认证上云抽好礼

汇聚全站年度销量TOP云产品,每天上午9点限量秒杀,优惠...

立刻前往...
阿里对象存储OSS
阿里对象存储OSS

个人新用户免费试用3个月;企业新用户免费试用3个月!...

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

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

立刻前往...
新用户专属大礼包
新用户专属大礼包

新客户无门槛领取总价值高达2860元代金券,先到先得。...

立刻前往...