Skip to content
Latchkey

dnf remove: Usage, Options & Common CI Errors

dnf remove uninstalls a package on the Red Hat family, with optional orphan cleanup.

dnf remove is the Red Hat-family counterpart to apt-get remove. It removes a package and, by default, anything that depends on it - so the cascade is worth reviewing before passing -y.

What it does

dnf remove uninstalls the named package and the packages that depend on it. dnf autoremove additionally clears dependencies that were installed automatically and are now unused. On RHEL 7 / CentOS 7, yum remove is the equivalent.

Common usage

Terminal
dnf remove -y nginx
dnf autoremove -y                                  # drop unused deps
yum remove -y httpd                                # CentOS 7 / RHEL 7
dnf remove -y nginx && dnf clean all

Common errors in CI

dnf remove pulls dependents with it, so removing a low-level library can cascade into removing far more than intended - read the transaction summary ("Removing:" / "Removing dependent packages:") before confirming. "No match for argument: X" means the name is wrong or the package is not installed. Removing a protected package (like dnf or systemd) is blocked with "Problem: The operation would result in removing the following protected packages". Pair removal with dnf clean all to reclaim cache space.

Options

ItemWhat it does
-y / --assumeyesAssume yes (required in CI)
autoremoveRemove unused automatic dependencies
remove <pkg>Uninstall a package and its dependents

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →