CentOS基础配置
:IT学习乐园
:Builder
:20240623
:637

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






华为内容分发网络
华为内容分发网络

CDN全时包,客户可享受0点到18点期间流量免费.综合价...

立刻前往...
注册认证上云抽好礼
注册认证上云抽好礼

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

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

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

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

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

立刻前往...