dnf Command Reference: Flags, Usage & CI Examples
dnf is the modern package manager for Fedora and current RHEL-family systems.
dnf is the successor to yum with faster dependency resolution and a similar command set. It manages RPM packages on Fedora, RHEL 8+, Rocky, Alma, and recent Amazon Linux.
Common flags and usage
- install <pkg...>: install packages
- -y / --assumeyes: assume yes to prompts
- --setopt=install_weak_deps=False: skip weak dependencies
- remove <pkg>: remove packages
- upgrade: upgrade installed packages
- clean all: clear cached metadata
Example
shell
dnf install -y --setopt=install_weak_deps=False postgresql gcc make
dnf clean allIn CI
Use -y for noninteractive installs and --setopt=install_weak_deps=False to skip recommended extras (the dnf equivalent of --no-install-recommends). Finish with dnf clean all to trim the image layer.
Key takeaways
- dnf is the modern replacement for yum on RHEL-family systems.
- -y and install_weak_deps=False give lean noninteractive installs.
- dnf clean all trims cached metadata from image layers.
Related guides
yum Command Reference: Flags, Usage & CI ExamplesReference for yum: install, -y, remove, makecache, clean all, and a CI example that installs packages noninte…
rpm Command Reference: Flags, Usage & CI ExamplesReference for rpm: -i, -U, -e, -q, -ql, -qf, and a CI example that installs a local .rpm and queries which pa…
apt-get Command Reference: Flags, Usage & CI ExamplesReference for apt-get: update, install, -y, DEBIAN_FRONTEND, --no-install-recommends, and a CI example that i…