08 修改自己的Centos的软件源

文章目录

前言

07 下载配置很完善的yum软件源

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

打开自己的Centos


觉得慢或卡的朋友,可以点击Enter,最多点两次就可以了,上面不用Enter也会默认选择第一个。

Centos展示界面


上面就懒得登录了,毕竟又不是不知道ip地址。

可能哪里配置不对,没有分配到ip地址,哈哈,打脸了。有知道的大佬可以说哈,小趴菜感激不尽。

DHCP 自动分配ip

ens32 网卡名

bash 复制代码
dhclient ens32

Ping 测试

MobaXterm远程连接

软件源 CentOS-Base.repo

bash 复制代码
# 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

修改自己的软件源

bash 复制代码
vi /etc/yum.repos.d/CentOS-Base.repo

删除原有软件源

先按 ESC,进入命令模式


鼠标滚轮滑到最后,dg默认删除开始行到光标所在行

插入准备的软件源

点一下i,进入到编辑模式

保存软件源

ESC先退出编辑模式,再SHIFT+:,然后输入wq,最后回车

使用软件源

yum clean all

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

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

执行命令

bash 复制代码
yum clean all

yum makecache

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

执行命令

bash 复制代码
yum makecache


测试软件源

小火车介绍

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

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

安装

bash 复制代码
yum install sl

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

解决方法如下:

  1. 首先安装EPEL仓库(适用于CentOS 7):
bash 复制代码
yum install epel-release -y
  1. 安装完成后,再执行安装sl的命令:
bash 复制代码
yum install sl -y


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

启动小火车

常用选项

  • -a :显示一辆带有烟囱的火车,同时会有小人正在呼救的场景,即事故模式。
  • -l :显示一辆更小的火车,且有更多车厢。
  • -F :让火车飞起来,类似银河快车999的效果。

    Ctrl+z 中断动画

基本用法

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

相关推荐
bug攻城狮5 小时前
彻底禁用 CentOS 7.9 中 vi/vim 的滴滴声
linux·运维·服务器·centos·vim
苹果醋35 小时前
数据库索引设计:在 MongoDB 中创建高效索引的策略
java·运维·spring boot·mysql·nginx
XMYX-06 小时前
Linux 物理机如何区分 SSD 与 HDD ——以 DELL PERC H730 Mini 为例
linux·运维
轻松Ai享生活6 小时前
5 天学习 Linux Kernel 主要原理 | Day 3:内存管理与Swap机制
linux
轻松Ai享生活6 小时前
QAT 与 GPU 在SHA-1 运算中的优劣
linux
行思理6 小时前
linux 安全与防护,全方向讲解
linux·安全·github
tan180°7 小时前
Boost搜索引擎 查找并去重(3)
linux·c++·后端·搜索引擎
yongui478347 小时前
CentOS系统如何查看当前内存容量
linux·运维·centos
xzq_java7 小时前
CentOS操作系统虚拟机安装以及连接工具下载和远程连接工具远程连接
linux·运维·centos