08 修改自己的Centos的软件源

发布于:2025-09-09 ⋅ 阅读:(23) ⋅ 点赞:(0)

前言

07 下载配置很完善的yum软件源
上面一个文章,我们说到,下载一个完善的Centos 7的软件源。那么本期文章就反过来,修改自己的Centos软件源,使其变成完善的软件源。

打开自己的Centos

在这里插入图片描述
觉得慢或卡的朋友,可以点击Enter,最多点两次就可以了,上面不用Enter也会默认选择第一个。

Centos展示界面

在这里插入图片描述
上面就懒得登录了,毕竟又不是不知道ip地址。
在这里插入图片描述
可能哪里配置不对,没有分配到ip地址,哈哈,打脸了。有知道的大佬可以说哈,小趴菜感激不尽。

DHCP 自动分配ip

ens32 网卡名

dhclient ens32

在这里插入图片描述

Ping 测试

在这里插入图片描述

MobaXterm远程连接

在这里插入图片描述

软件源 CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

修改自己的软件源

vi /etc/yum.repos.d/CentOS-Base.repo

在这里插入图片描述

删除原有软件源

先按 ESC,进入命令模式

在这里插入图片描述
鼠标滚轮滑到最后,dg默认删除开始行到光标所在行

插入准备的软件源

点一下i,进入到编辑模式
在这里插入图片描述

保存软件源

ESC先退出编辑模式,再SHIFT+:,然后输入wq,最后回车
在这里插入图片描述

使用软件源

yum clean all

作用:清理并清理 YUM 缓存的所有数据,包括:

  • 已下载的软件包安装文件(/var/cache/yum/ 目录下的 rpm 包)
  • 仓库元数据(软件包列表、依赖关系等信息)

执行命令

yum clean all

在这里插入图片描述

yum makecache

作用:重新生成 YUM 缓存,即从配置的软件仓库中下载并存储最新的软件包元数据(包括包列表、版本信息、依赖关系等)到本地。

执行命令

yum makecache

在这里插入图片描述
在这里插入图片描述

测试软件源

小火车介绍

在 CentOS 7 中,sl命令是一个有趣的终端动画工具,它会在终端中显示一辆蒸汽火车的动画效果。

sl(Steam Locomotive)最初由日本开发者Toyoda Masashi编写,主要功能是在终端中显示一辆从左到右行驶的蒸汽火车,虽然没有实际的运维用途,但可以为枯燥的命令行环境增添一些乐趣。

安装

yum install sl

在这里插入图片描述
在CentOS中直接使用yum install sl安装失败,是因为sl软件包不在CentOS默认的基础仓库中,需要先启用EPEL扩展仓库(Extra Packages for Enterprise Linux)。

解决方法如下:

  1. 首先安装EPEL仓库(适用于CentOS 7):
yum install epel-release -y

在这里插入图片描述
2. 安装完成后,再执行安装sl的命令:

yum install sl -y

在这里插入图片描述
原理说明:EPEL 仓库包含了许多不在 CentOS 官方仓库中的实用软件包,sl就是其中之一,所以需要先启用这个扩展仓库才能安装。

启动小火车

在这里插入图片描述

常用选项

  • -a:显示一辆带有烟囱的火车,同时会有小人正在呼救的场景,即事故模式。
    在这里插入图片描述
  • -l:显示一辆更小的火车,且有更多车厢。
    在这里插入图片描述
  • -F:让火车飞起来,类似银河快车999的效果。
    在这里插入图片描述
    Ctrl+z 中断动画

基本用法

安装完成后,直接在终端中运行sl命令,就会看到一辆蒸汽火车从终端左侧驶向右侧。如果想要让小火车一直跑下去,可以使用命令while true;do sl;done,按下Ctrl+z可停止循环。
在这里插入图片描述


网站公告

今日签到

点亮在社区的每一天
去签到