温馨提示×

Debian如何配置yum

小樊
41
2026-07-02 08:02:06
栏目: 智能运维

Debian 不支持也不应该使用 yum
yumRed Hat 系列(RHEL、CentOS、Fedora 等) 的包管理工具,而 Debian / Ubuntu 使用的是 APT(Advanced Package Tool)


一、Debian 正确的包管理方式(APT)

1️⃣ 更新软件源

sudo apt update

2️⃣ 安装软件

sudo apt install nginx

3️⃣ 升级系统

sudo apt upgrade

4️⃣ 删除软件

sudo apt remove nginx

二、Debian 软件源配置文件

Debian 的软件源配置在:

/etc/apt/sources.list

/etc/apt/sources.list.d/*.list

示例(Debian 12 Bookworm):

deb http://deb.debian.org/debian bookworm main contrib non-free
deb http://deb.debian.org/debian bookworm-updates main contrib non-free
deb http://security.debian.org/debian-security bookworm-security main

修改后执行:

sudo apt update

三、如果你“必须用 yum”(不推荐)

✅ 情况 1:运行 CentOS / RHEL 容器

docker run -it centos bash
yum install vim

✅ 情况 2:误把 Debian 当 CentOS 用

停止尝试安装 yum,这是错误方向。


四、常见误区对比

系统 包管理器
Debian / Ubuntu apt / dpkg
CentOS / RHEL yum / dnf
Arch pacman
openSUSE zypper

五、如果你原本想做的事

你可以告诉我:

  • ✅ 想安装什么软件?
  • ✅ 从 CentOS 迁移到 Debian?
  • ✅ 想用国内镜像源?

我可以给你 Debian 对应 yum 命令的 apt 写法国内源配置方案

0