You may know this problem. You have a lot of packages installed on your Ubuntu / Debian system and (for whatever reason) you want that a specific packages isn’t getting updated whenever you do a system upgrade. This short article is going to show you how to prevent packages from being updated.
APT or Aptitude?
Debian / Ubuntu basically has two ways to manage packages. To be more specific there are two package managers which can be used on the console for updating, installing and removing packages / software under your Ubuntu / Debian system. These two solutions are APT and Aptitude. This article describes how to prevent packages from being updated with both solutions.
How to prevent packages from being updated.
You can always prevent packages from being updated with the help of APT. APT comes with every Ubuntu / Debian installation, so the following command should definitely work on any Debian / Ubuntu based system:
user@system:~$ sudo apt-mark hold <name of the package>
You have to change <name of the package> with the package you want to hold of course. So for e.g. if you want to prevent vlc from getting updated, the command would look like this:
user@system:~$ sudo apt-mark hold vlc
If you’re and Aptitude user instead, the command (with the exact same result) would look like this:
user@system:~$ sudo aptitude hold vlc
If you now update your system with the classical apt-get upgrade command for e.g., the package vlc isn’t going to be upgraded. APT, as well as Aptitude, will echo a notice which is saying that the package has been prevented from being updated.
How to unhold the package?
So, to hold a package is rather easy. But what to do when you want to unhold this package in order to get it updated again? If we use our vlc package from the example above again, the command to unhold and make a package available for an update with APT looks like this:
user@system:~$ sudo apt-mark unhold vlc
Again, the same command with the exact same result in Aptitude does look like this:
user@system:~$ sudo aptitude unhold vlc
But why to hold a package anyway?
You may ask yourself why you should hold a package anyway. Well, there are several reasons to do this. For e.g. sometimes you update a package and after this update the software doesn’t work as expected. So if you encounter a problem after an update on a test system, you could hold / block the specific package which causes you trouble on a production system before updating the system. Another example would be that you might have to check the configuration files first before updating a specific software. However, you want to install the latest security updates for the other installed packages. With holding the package you can update the other packages without touching the once you block.
Of course there are many other reasons why holding a package is a useful and a needed feature. You can also do this with a graphical solution like Synaptics. However, the console way of holding a package is much more easier and faster (IMHO) 😉
- Image header source: wikipedia.org