← 返回命令列表

Linux command

dnf 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Upgrade

sudo dnf upgrade

Search

dnf search [keyword]

Example

dnf info [package]

Install

sudo dnf install [package]

Remove

sudo dnf remove [package]

Example

dnf list --installed

Example

dnf provides [command]

Clean

sudo dnf clean all

说明

dnf (Dandified YUM) is the package manager for Fedora, RHEL, and related distributions. It has been the default since Fedora 22, with DNF5 becoming the default in Fedora 41+. It is the successor to YUM and provides improved dependency resolution, performance, and a more consistent interface.

参数

install, in package
Install specified packages
remove, rm package
Remove specified packages
upgrade, up
Upgrade all installed packages
search, se keyword
Search for packages matching keyword
info, if package
Display detailed information about a package
list, ls
List packages (--installed, --available, --updates)
provides command
Find packages providing a file or command
clean option
Clean cached data (all, dbcache, expire-cache, metadata, packages)
repolist
Display configured repositories
history
View transaction history
autoremove
Remove unneeded packages
-y, --assumeyes
Automatically answer yes to prompts
--refresh
Set metadata as expired before running command

FAQ

What is the dnf command used for?

dnf (Dandified YUM) is the package manager for Fedora, RHEL, and related distributions. It has been the default since Fedora 22, with DNF5 becoming the default in Fedora 41+. It is the successor to YUM and provides improved dependency resolution, performance, and a more consistent interface.

How do I run a basic dnf example?

Run `sudo dnf upgrade` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does install, in package do in dnf?

Install specified packages