溫馨提示×

ubuntu怎么配置yum源

小億
211
2023-11-03 15:38:08
欄目: 智能運維

在Ubuntu系統(tǒng)中,yum是Redhat系列的Linux發(fā)行版中的軟件包管理工具,而Ubuntu則使用apt作為軟件包管理工具。因此,在Ubuntu系統(tǒng)中,我們需要配置apt源而不是yum源。

要配置apt源,請按照以下步驟進行操作:

  1. 打開終端。

  2. 進入sources.list文件所在目錄。輸入以下命令:

cd /etc/apt/
  1. 備份sources.list文件。輸入以下命令:
sudo cp sources.list sources.list.bak
  1. 編輯sources.list文件。輸入以下命令:
sudo nano sources.list
  1. 在編輯器中,刪除所有內(nèi)容,然后將以下內(nèi)容粘貼到文件中:

對于Ubuntu 20.04版本(Focal Fossa):

deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse

對于其他版本的Ubuntu,請將上述內(nèi)容中的“focal”替換為您正在使用的Ubuntu版本的代號。

  1. 保存并關(guān)閉文件。按下Ctrl + X,然后按Y,最后按下Enter鍵。

  2. 更新apt源。輸入以下命令:

sudo apt update

配置完成后,您就可以使用apt命令來安裝、更新和移除軟件包了。例如,輸入以下命令來安裝一個軟件包:

sudo apt install 軟件包名稱

希望對您有幫助!

0