用 dnf history undo 回滚软件包事务
dnf history 会为每次安装/升级事务记录编号,history undo 可以逐包撤销指定事务。
运行 `sudo dnf history` 列出带编号的历史事务,然后运行 `sudo dnf history undo <编号>` 撤销指定事务。
01命令
命令
$ sudo dnf history02作用说明
dnf 的每个操作都会写入带编号、时间戳和操作用户的事务历史——`dnf history info <编号>` 可查看具体安装、升级或删除了哪些包。`dnf history undo <编号>` 执行逆向操作,`history rollback <编号>` 则把系统回滚到该事务完成时的状态。当一次更新破坏了系统而你想做包级别的还原而非虚拟机快照回滚时,这就是那个容易被遗忘的安全网。
03风险
!注意: undo 只作用于软件包层面——不会还原软件包修改过的配置文件或执行过的数据库迁移。
04撤销
撤销
$ sudo dnf history undo <transaction-id>05来源
- DNF Command Reference — history commands依据: dnf history lists transactions, dnf history info <id> shows details, and dnf history undo <id> repeats the inverse of the specified transaction.
最后验证: 2026-09-17 · 分类: 系统与设置