centos7如何更新yum源

小億
314
2023-11-23 02:15:40

在CentOS 7上更新yum源,可以按照以下步驟進(jìn)行操作:

  1. 打開(kāi)終端,以root用戶身份登錄。

  2. 備份原始的yum源配置文件:

    cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
    
  3. 編輯CentOS-Base.repo文件:

    vi /etc/yum.repos.d/CentOS-Base.repo
    
  4. 在文件中,將[base]、[updates]、[extras]、[centosplus]等節(jié)的baseurlmirrorlist行注釋掉(在行首添加#符號(hào)),然后將以下內(nèi)容添加到每個(gè)節(jié)的末尾:

    baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
    
  5. 保存并退出vi編輯器。

  6. 清理yum緩存:

    yum clean all
    
  7. 更新yum源:

    yum makecache
    

現(xiàn)在,您的CentOS 7系統(tǒng)的yum源已經(jīng)成功更新為163.com的鏡像源。您可以使用yum命令來(lái)安裝、更新和刪除軟件包。

0