This post describes how to exclude specific packages from being updated with Fedora and dnf or yum
How to exclude packages from updating
To exclude a package or set of packages you can use the command line flag
--exclude with dnf or yum.
All command snippets will include the command for running with yum or dnf. dnf replaced yum as the default package management system as of Fedora 22 so if you are running this distribution or later you will want to use the dnf commands.
The update command accepts a package name to exclude for updating. For example you can run the following commands with yum or dnf.
sudo dnf update --exclude=firefox
sudo yum update --exclude=firefox
This command would look to update all packages on the system apart from
firefox. In addition to matching a specific package wildcards can be used.
For example, if I want to update everything except kernel packages I can run:
sudo dnf update --exclude=kernel*
sudo yum update --exclude=kernel*
Here all packages would be updated apart from those that begin with
Why you might want to exclude some packages
Using the exclude flag can come in handy in a number of situations. For example you may want to use this to only update specific packages on virtual machines.
Many virtual machines will have specific kernel modules compiled to better handle virtualization. An example would be Virtualbox Guest Additions. Here you have to compile a module for your specific kernel version. If you were to update the kernel the module would no longer work. This would then mean you would need to reinstall this module.
Therefore it can be helpful in certain circumstances when you know you don’t want to update a package to exclude it from the list.
A small warning…
There must be a small warning with excluding packages when updating your machine. By doing this you are explicitly stopping certain packages from updating. Before you do this you should check to see if the update you are missing is not an important security update.
However excluding packages can be helpful when you know that an update will cause issues for your system.
Hopefully this can help people who need to exclude certain packages from updates. However as noted above there needs to be a small amount of caution when doing so. Stopping certain packages from updating can prevent issues however there is always a chance of exposing yourself to others by not updating.