Skip to content
Search RHEL

This page uses Chinese content. Search opens the Chinese documentation.

    Browse this documentation

    RHEL 10 的 dnf 仍是 4.20:dnf5 迁移前先确认什么

    This content is not available in your language yet.

    很多“RHEL 10 用 dnf5”的说法并不准确:RHEL 10.2 默认仍是 dnf 4.20,dnf5 连包都没有。迁移脚本前,先把版本和现有命令核对清楚,别按 dnf5 的语法改。

    在 PVE 390 rhel10-lab(RHEL 10.2)执行:

    Terminal window
    dnf --version
    rpm -q dnf
    rpm -q dnf5 || true
    command -v dnf5 || echo no-dnf5

    E3 记录:plans/content-expansion/evidence/rhel/rhel-dnf5/run.json(4 步,含版本、repoquery、history、assumeno)。

    $ dnf --version
    4.20.0
    $ rpm -q dnf
    dnf-4.20.0-22.el10_2.noarch
    $ rpm -q dnf5
    package dnf5 is not installed
    $ command -v dnf5
    (空)

    所以:

    • 现有脚本继续按 dnf4 写;
    • 不要假设 dnf5 子命令/参数存在;
    • 真要做 dnf5 兼容,等 RHEL 版本实际提供 dnf5 后再按差异测试。
    $ dnf -q repoquery --latest-limit 1 bash
    bash-0:5.2.26-6.el10.x86_64

    repoquery 在 dnf4 里是插件;--latest-limit、--qf 等参数可用。

    $ dnf -q history --reverse | head -4
    ID | Command line | Date and time | Action(s) | Altered
    1 | -q -y install zsh | 2026-11-04 02:28 | Install | 1
    2 | -q -y history undo last | 2026-11-04 02:28 | Removed | 1
    3 | -q -y install zsh | 2026-11-04 02:28 | Install | 1

    history undo 依赖 dnf4 的事务 ID;迁移到 dnf5 前要确认新工具是否保留同样的 history/undo 语义。

    $ sudo dnf -y --assumeno install nano
    ...
    Operation aborted.

    --assumeno 用来“只算事务不执行”,在 dnf4 仍有效;自动化里比 --downloadonly 更安全。

    • dnf --version 确认 4.x/5.x;
    • command -v dnf5 是否存在;
    • 脚本是否用了 dnf5 专属参数;
    • repoquery/history/--assumeno 是否仍可用;
    • 插件(versionlock/config-manager)是否随 dnf 版本变化;
    • 在目标 RHEL 小版本上重跑,而不是只在文档里看。
    • 未安装 dnf5,未测试 dnf5 命令差异;
    • 未测试 dnf5 插件/模块流;
    • 未测试 dnf4→dnf5 的 history 兼容;
    • 未测试 microdnf/容器内 dnf。