disable package updates in linux

How to Stop Linux Package Update in Ubuntu

Sometimes you may need to disable package updates in Linux. In this article, we will look at how to stop Linux package update in Ubuntu.


How to Stop Linux Package Update in Ubuntu

There are different ways to disable updates for specific package.


1. Using dpkg

Open terminal and run the following command to disable updates for your package, that is, to put their updates on hold. Replace apache2 below with your package name.

$ sudo echo "apache2 hold" | sudo dpkg --set-selections

Here is the command to remove the hold on this package.

$ sudo echo "apache2 install" | sudo dpkg --set-selections

You can use the following command to list all packages on hold.

$ dpkg --get-selections | grep "\<hold$" 


2. Using apt-mark

You can also use apt-mark tool to disable updates for a package. Here is the syntax for it. Replace <package-name> below with your package’s name e.g. apache2.

$ sudo apt-mark hold <package-name>

Here is the command to remove hold for your package.

$ sudo apt-mark unhold <package-name>

Here is the command to list all packages on hold.

$ sudo apt-mark showhold


3. Using aptitude

Similarly, you can also use aptitude tool to disable updates for specific package.

$ sudo aptitude hold <package-name>

Here is the command to remove hold on specific package.

$ sudo aptitude unhold <package-name>


4. Using /apt/preferences

/etc/apt/preferences contains list of packages with their update priorities. You can also edit it to list your package whose updates you want to disable. Open it in a text editor.

$ sudo vi /etc/apt/preferences

Add the following lines to disable updates for package apache2.

Package: apache2 
Pin: release o=Ubuntu 
Pin-Priority: -1

In the above lines, you need to enter package name, pin and pin-priority (value<0) to disable its updates. We have used -1 pin-priority to disable updates. Save and close the file to apply changes.

You may also use Synaptic Package Manager or dselect to disable updates using a GUI.

That’s it. In this article, we have looked at 4 different ways to disable updates for specific Linux packages.

Also read:

How to Generate PGP Key in Ubuntu
How to Log Shell Script Output to File
Find PID of Process Running on Port
How to Check if Port is Open or Closed in Linux
How to Determine Kernel Architecture in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *