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
dnf remove -y nginx
dnf autoremove -y # drop unused deps
yum remove -y httpd # CentOS 7 / RHEL 7
dnf remove -y nginx && dnf clean allCommon 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
| Item | What it does |
|---|---|
| -y / --assumeyes | Assume yes (required in CI) |
| autoremove | Remove unused automatic dependencies |
| remove <pkg> | Uninstall a package and its dependents |