linux更换yum源 (一看就懂)

本文介绍了Linux中yum源的作用,它是一个用于Fedora、RedHat和CentOS的包管理器,负责自动处理软件包依赖并安装。文章详细讲解了如何使用yum命令进行搜索、列出已安装包、安装、移除、更新和检查更新等操作。同时,还阐述了更换yum源的步骤,包括备份原有yum源文件,编辑新的yum源配置,最后执行yum缓存更新和系统更新。
摘要由CSDN通过智能技术生成

什么是yum源?

**yum(全称为 Yellow dog Updater, Modified)**是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

  • linux 里 一些插件和软件都是由yum 控制下载和安装 不同的yum源下载的权限可能不同,有的yum源支持的软件可能在另一个yum中就不支持…
命令行作用示例
yum search 搜索软件包yum search python
yum list installed列出已经安装的软件包yum list installed
yum install 用来安装指定的软件包yum install vim
yum remove用来移除软件包yum remove vim
yum update 更新软件包yum updat tar
yum check-update检查更新yum check-update
yum info 列出指定软件包详情yum info python

查看yum源

yum repolist ## 查看当前安装的yum源版本 详细信息

在这里插入图片描述
这里是已经安装好的清华yum源

更换步骤

1. 找到yum目录位置 拷贝原有的yum文件 养成好的习惯
[root@localhost ~]# 
cd /etc/yum.repos.d/
# etc 用来存放所有的系统管理所需要的配置文件和子目录。(会经常使用)
# 在此目录下 我们可以查看一下有哪些文件
ls -al
#总用量 72
drwxr-xr-x.   2 root root 4096 1月  14 18:17 .
drwxr-xr-x. 145 root root 8192 1月  14 17:16 ..
-rw-r--r--.   1 root root 1664 1月  14 18:00 CentOS-Base.repo
-rw-r--r--.   1 root root 1664 8月  30 2017 CentOS-Base.repo.backup
-rw-r--r--.   1 root root 2523 1月  14 17:55 CentOS-Base.repo.bak
-rw-r--r--.   1 root root 1309 11月 23 23:08 CentOS-CR.repo
-rw-r--r--.   1 root root  649 11月 23 23:08 CentOS-Debuginfo.repo
-rw-r--r--.   1 root root  314 11月 23 23:08 CentOS-fasttrack.repo
-rw-r--r--.   1 root root  630 11月 23 23:08 CentOS-Media.repo
-rw-r--r--.   1 root root 1331 11月 23 23:08 CentOS-Sources.repo
-rw-r--r--.   1 root root 8515 11月 23 23:08 CentOS-Vault.repo
-rw-r--r--.   1 root root  616 11月 23 23:08 CentOS-x86_64-kernel.repo
-rw-r--r--.   1 root root 1050 11月  1 04:33 epel.repo
-rw-r--r--.   1 root root 1149 11月  1 04:33 epel-testing.repo

 cp CentOS-Base.repo CentOS-Base.repo.bak  # 拷贝 此文件 存放的yum源文件
 
 vim CentOS-Base.repo  #进入 文件  按i进入编辑模式将你需要的yum源文件替换进去 这里下方以清华yum源为例子
  • 将下面的替换进去就可以了
# 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
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7

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



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



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

  • esc 回到底部编辑模式 然后:wq! 保存
2.配置 运行yum
  • 注意: cd / 回到根目录进行下面的操作
yum makecache   #一步一步完成
# 完成后 执行下面命令 对yum源更新就好了
yum clean all
yum update    
# 之后就可以在yum里下载更新软件了 

hell
yum makecache #一步一步完成


```shell
# 完成后 执行下面命令 对yum源更新就好了
yum clean all
yum update    
# 之后就可以在yum里下载更新软件了 
```



  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值