dnf install
Packages and runtimes
Usage
sudo dnf install [-y] <package>Installs from the enabled repositories and resolves dependencies, refreshing metadata on its own expiry so there is no separate update step as with apt; on RHEL 8 and later yum is a link to dnf, and Fedora 41 moved to dnf5.
Common flags
| Flag | Meaning |
|---|---|
| -y | assume yes |
| --refresh | expire the metadata cache before resolving |
| --enablerepo=<repo> | use a repository that is off by default |
| --setopt=install_weak_deps=False | skip weak dependencies |
| --allowerasing | let it remove packages to satisfy the request |
| --nogpgcheck | install without checking signatures |
Examples
sudo dnf install -y gitinstalls with dependencies from the enabled repos
sudo dnf install --refresh nginxrefreshes metadata first, then installs
sudo dnf install ./package.rpminstalls a local rpm and resolves its dependencies
The question is always what goes where: inside this project, or on the whole machine.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does dnf install do?
Installs from the enabled repositories and resolves dependencies, refreshing metadata on its own expiry so there is no separate update step as with apt; on RHEL 8 and later yum is a link to dnf, and Fedora 41 moved to dnf5.
Q. How do I type it?
sudo dnf install [-y] <package> — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
6 are listed here; the full set is in man dnf. This command sits under Packages and runtimes.
Related commands
man page: man dnf-install