严格来说:Ubuntu 不能直接安装或使用 yum 源。因为:
yum 只能读取 .rpm 仓库.debyum,也无法正常使用✅ 正确的做法:使用 APT 源,而不是 yum 源
sudo apt update
sudo apt install 软件名
软件源配置文件在:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list
比如安装较新版本软件:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.2
例如 Docker(官方示例):
sudo apt update
sudo apt install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce
✅ 这是 Ubuntu 中“添加仓库”的正确方式
可以安装,但 ❌ 不推荐、几乎没用
sudo apt update
sudo apt install yum
但:
可以使用:
sudo apt install rpm
但只能:
| 需求 | CentOS / RHEL | Ubuntu |
|---|---|---|
| 包管理器 | yum / dnf | apt |
| 仓库格式 | .repo | .list |
| 软件包 | .rpm | .deb |
| 添加仓库 | yum repo | apt source / PPA |
✅ Ubuntu 不需要、也不能安装 yum 源
✅ 请使用 APT 源 / PPA / 官方 APT 仓库
如果你是因为:
可以把 具体软件名或报错贴出来,我可以帮你用 Ubuntu 原生的正确方式 实现 ✅