I've got a temporary situation where I'm working with pre-release F27, and need to keep one package to a specific (working) version and not be upgraded until the subsequent versions stop breaking something. I know in general "you don't really want to do this", but as I said, it's a temporary dealing with a pre-rel system. You can "pin" packages with the apt system, but I can't locate anything equivalent for dnf.

3 Answers 3


The Fedora docs now have a Quick Doc to address this question. To summarize here:

To pin a package, there is the versionlock plugin available as part of dnf-plugins-core package. See man dnf-versionlock.

sudo dnf install 'dnf-command(versionlock)'

sudo dnf versionlock add <package-name-spec>
sudo dnf versionlock delete <package-name-spec>
sudo dnf versionlock list
sudo dnf versionlock clear    # Removes all versionlocks
sudo dnf versionlock exclude  # Also possible here

To exclude a package from a transaction

sudo dnf upgrade --exclude=packagename   

or add to /etc/dnf/dnf.conf

excludepkgs=package-name   // See `man dnf.conf` for more

The difference between excluding and pinning (dnf: versionlock) is that to exclude a package is to tell dnf to ignore a package from a transaction entirely, whereas to versionlock a package is to recognize the package but explicitly request that it be held at a specific version. The distinction is important because excluding a package also applies to dnf search, dnf repoquery, etc. and is effectively to operate as if the package didn't exist.

Hence for the question:

  • You probably want to versionlock since this does exactly what you want. This will also help remind you that you have a package pinned since you can dnf updateinfo --list and still see that a later version is available, which is not true if it has been exclude-ed. Aside: a dnf check-update will not show a pinned (or excluded) package, since literally in this sense there is nothing to update.

  • In contrast, to exclude a package is a broader statement - perhaps you (or your sysadmin) doesn't want to touch a set of packages at all or simply because you want to ignore a package during some set of transactions for some reason.

    For example, exclude applies equally to

      dnf search <keywords> --exclude=packagename 

Finally, a note that the above applies directly to the given package-name, independent of its dependencies. However, I observe that a dnf update will still correctly refuse to update any packages that would break due to a held package (and will helpfully tell you that these are being skipped).


The excludepkgs configuration option in dnf.conf lists packages that dnf should never try to install or upgrade; in a repo section it affects only that repo, in [main] all repos are affected. See the dnf.conf(5) man page for details.

  • After a misstep or two, that seems to work. Thanks! Commented Nov 8, 2017 at 13:57
  • @mats-wichmann please accept the answer as it was helpful for you (for me as well)
    – user124813
    Commented Nov 9, 2017 at 9:10

Excluding can also be obtained using --exclude=package, but "excluding" and "pinning" are different actions, hence the correct solution for pinning is to use:


which replaces:


there is a difference in the way, the configuration file works between yum and dnf and I don't have a correct answer for dnf (I didn't go through the man page yet). Hence I am not adding furter details. it seems that it was inverted the order used to specify package and epoc number. dnf man-page does not mention "epoc" (you can check an older system for this man page).

in yum it was:


in dnf it is:


to understand, what this means, you can run for instance:

dnf versionlock add bash

and check the content of the file:

cat /etc/dnf/plugins/versionlock.list

# Added locks on Fri Aug 28 17:30:58 2020
  • Since your answer seems to have come in several years after the accepted one can you highlight why, in your opinion, this plugin in superior to the accepted answer which doesn't require additional software?
    – nhed
    Commented Dec 18, 2020 at 15:44
  • 1
    @nhed "pinning" and "excluding" are entirely different actions. If you install a server from scratch, if you exclude a package, you will only stick with its initial version, but not a specific pinned version. And it can be a different version. If you have a twin server, and you want the same versin, or if your testing is based on a specific version, you have to use pinning.
    – maxadamo
    Commented Dec 20, 2020 at 0:11
  • ok, this should probably be integrated into your answer. But for the OP's scenario where he already has something that works and he wants to just buy some time till a problem is fixed I suspect either will work and with the accepted solution he does not need to install any plugins. The real pinning seems useful for reproducible builds etc
    – nhed
    Commented Dec 23, 2020 at 1:21

You must log in to answer this question.

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