CentOS中yum知識點
阿新 • • 發佈:2022-05-08
1. yum中$releasever、 $basearch等變數含義
linux社群:[yum中$releasever、$bashsearch變數含義] https://www.linuxidc.com/Linux/2018-05/152526.htm
$releasever
您可以使用此變數來引用 Red Hat Enterprise Linux 的發行版本。
Yumo 從 /etc/yum.conf 配置檔案中的 distroverpkg=value 行獲取 $releasever 的值。
如果 /etc/yum.conf 中沒有這樣的行,則 yum 通過從 redhat-release 包中派生版本號來推斷正確的值。
# rpm -qi centos-release #檢視centos version版本號
$basearch
您可以使用 $basearch 來引用系統的基本架構。
例如,i686 和 i586 機器的基礎架構都是 i386,而 AMD64 和 Intel64 機器的基礎架構是 x86_64。
2.yum源更換成國內映象 【CentOS 8】
阿里雲開發者社群:[CentOS 8解決yum不能更新源問題] https://developer.aliyun.com/article/748336
# cd /etc/yum.repos.d/
# mv CentOS-Base.repo CentOS-Base.repo.bak #備份yum源
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
# sed -i 's/$releasever/8/g' /etc/yum.repos.d/CentOS-Base.repo #替換$releasever為8
# yum clean all #清理快取
# yum makecache #更新源
補充知識點:
除了sed命令通過指令碼處理檔案,也可以手動全文替換 # vi CentOS-Base.repo :%s/$releasever/8/g #替換每一行中所有 $releasever 為 8