apt upgrade may install additional packages if required. It will never remove packages. (When upgrading the distribution version, a different command is used, which may remove packages). [1]

I would like to know what dnf upgrade does in the same cases -

Does dnf upgrade install additional packages if required?

Could dnf upgrade ever remove packages?

[1] See this answer: apt-get upgrade holds back a kernel update. What are the official instructions for applying updates on Debian 9?

  • @ThomasDickey my dnf man page does not explicitly say one way or the other. Since the apt man page does, I am looking for some confirmation. In fact, a different section of the dnf man page appears to explicitly say that dnf upgrade does not auto-remove, which would be surprising to users used to dnf remove. I am asking for an explicit answer to remove surprises. If simply quoting the dnf man page would provide such an answer, why not do so? Comments are not intended for answers.
    – sourcejedi
    Commented Sep 1, 2018 at 15:16
  • @ThomasDickey my dnf manpage is provided by the version dnf-2.7.5-12.fc28.noarch.
    – sourcejedi
    Commented Sep 1, 2018 at 15:18
  • 1
    If I really wanted to know, I'd look at the source. Saves time. Commented Sep 1, 2018 at 15:59

1 Answer 1


Does dnf upgrade install additional packages if required?

Yes. I tested dnf upgrade --releasever=28 on Fedora 27, and it proposed installing additional packages.

Could dnf upgrade ever remove packages?

dnf upgrade will remove packages which are no longer needed (and were not manually installed?), if the obsoletes option is set. Despite man dnf showing an option --obsoletes, the obsoletes option is actually enabled by default. (And dnf.conf does not unset the default, unless you changed it).

(dnf upgrade is basically trying to mimic yum upgrade. See also this answer: In CentOS, what is the difference between yum update and yum upgrade?)

There is also an option --allowerasing, "Allow erasing of installed packages to resolve dependencies." In this case, I can only assume that the option is not enabled by default. And hence if you don't specify the option, the day-to-day dnf commands will never erase installed packages to resolve dependencies. (Although you don't have to pass this option to the command for distribution version upgrades, dnf system-upgrade).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .