Skip to content
Latchkey

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 all

In 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →