CentOS 8 安装更新国内清华大学源手记【亲测成功】

一直和各种OS打交道,仍觉得自己是小白,故深知小白们的困惑和蛋碎,特此将安装更新源的细节和步骤做了详细整理,供大家参考。红字是命令和提示,深灰色代码框中是源配置,本文采用了清华大学CentOS 8的源,按提示操作可成功,祝你好运!Good Luck!

转载请注明出处:

 

首先备份 cd /etc/yum.repos.d/

[tony@localhost home]$ su

Password: 【输入root用户的密码获取root用户权限】

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

【PS:在有的版本CentOS 8 安装完成后在源目录“/etc/yum.repos.d/” 中并没有 CentOS-Base.repo 这个文件,可能报错,那么直接用vi命令创建这个文件,并粘贴本文所附的源代码,继续往下执行即可】

[root@localhost yum.repos.d]# ll
total 56
-rw-r--r--. 1 root root  731 Mar 12 15:15 CentOS-AppStream.repo
-rw-r--r--. 1 root root 2100 Apr 10 07:19 CentOS-Base.repo
-rw-r--r--. 1 root root  798 Mar 12 15:15 CentOS-centosplus.repo
-rw-r--r--. 1 root root 1043 Mar 12 15:15 CentOS-CR.repo
-rw-r--r--. 1 root root  668 Mar 12 15:15 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  743 Mar 12 15:15 CentOS-Devel.repo
-rw-r--r--. 1 root root  756 Mar 12 15:15 CentOS-Extras.repo
-rw-r--r--. 1 root root  338 Mar 12 15:15 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  738 Mar 12 15:15 CentOS-HA.repo
-rw-r--r--. 1 root root  928 Mar 12 15:15 CentOS-Media.repo
-rw-r--r--. 1 root root  736 Mar 12 15:15 CentOS-PowerTools.repo
-rw-r--r--. 1 root root 1382 Mar 12 15:15 CentOS-Sources.repo
-rw-r--r--. 1 root root   74 Mar 12 15:15 CentOS-Vault.repo
-rw-r--r--. 1 root root  173 Apr 10 06:47 google-chrome.repo
[root@localhost yum.repos.d]# 

创建CentOS-Base.repo 文件并写入源配置

[root@localhost yum.repos.d]# vi 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.
#
#

[BaseOS]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[AppStream]
name=CentOS-$releasever - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[PowerTools]
name=CentOS-$releasever - PowerTools
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=PowerTools&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

"ESC"键,输入:"wq" 保存并退出vi编辑器,然后执行下面的命令重新编译源缓存并执行更新操作:

[root@localhost yum.repos.d]# yum makecache 

[root@localhost yum.repos.d]# yum -y update

 

 

 

  • 3
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
清华大学 CentOS Base.repo 是一个软件配置文件,用于访问清华大学提供的 CentOS 软件仓库。CentOS 是一个基于 RHEL(Red Hat Enterprise Linux代码构建而成的开操作系统,而清华大学则提供了一个在中国用户中非常受欢迎的 CentOS 镜像,因此,用户可以通过配置 CentOS Base.repo 来使用清华大学的软件仓库。 CentOS Base.repo 的配置文件通常位于 `/etc/yum.repos.d/CentOS-Base.repo` 路径下,通过编辑该文件,用户可以指定软件更新安装时所使用的镜像。在清华大学提供的 CentOS 镜像中,可以包含各类软件包、更新和安全补丁,用户可以通过 yum 命令从该镜像中下载这些软件。 清华大学 CentOS Base.repo 的配置文件通常包含以下几个部分: 1. [base] 部分:提供基本的软件包和系统组件。 2. [updates] 部分:提供最新的软件包更新。 3. [extras] 部分:提供额外的软件包。 4. [centosplus] 部分:提供一些非 CentOS 原生的软件包。 用户可以根据自己的需求调整这些部分的配置选项,以便从清华大学镜像中获取所需的软件和系统更新。配置完 CentOS Base.repo 后,可以使用 yum 命令进行软件包的搜索、安装更新操作。 总之,清华大学提供的 CentOS Base.repo 是一个方便用户访问清华大学CentOS 镜像的配置文件,在使用清华大学CentOS 镜像时,用户可以通过编辑该文件来满足自己的软件更新安装需求。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值