How to hold/lock Packages in Ubuntu with example

Learn how to hold lock Packages in Ubuntu

In this article, we are going to shows that how to hold/lock Packages in  Ubuntu 18.04 | 20.04. If you want to lean that how to hold/lock Packages in your ubuntu then this post is ideal for you.

In the Linux, there are some special cases when you don’t want to update and upgrade a particular installed package because the updating process will change the custom configuration settings.

For an example, if you have a apache2 web server that is configured with custom settings and if you update it then it will change the custom configuration setting of Apache web server.

To avoid a package from being updated, you can use package hold feature that is known as package holding.

The command apt-mark is used to mark or unmark a package or software as being automatically installed and you can use this command with option hold or unhold.

  1. hold – this option is used to Prevent the package from being installed, upgraded or uninstall.
  2. unhold – this option used to remove hold on a package and allow to install, upgrade and uninstall.

Option 1 : Hold/Lock Packages Using Apt Package Manager

Simply follow below steps to hold / lock Packages in your Ubuntu system:

Show locked or held packages via command line :

To see all packages that are locked or being held , run the command below:

sudo apt-mark showhold

The above command will show the all packages that are on hold.


Hold or lock a package

To hold or lock a specific package, run the command below:

sudo apt-mark hold <package-name>

Replace <package-name> with the package that you want to hold or lock.

sudo apt-mark hold apache2

OR

Use the command below for aptitude,:

sudo aptitude hold <package-name>

Replace <package-name> with the package that you want to hold or lock.

sudo aptitude hold apache2

Unlock a package

To unlock a package for continue to get updates, run the command below:

sudo apt-mark unhold <package-name>

Replace <package-name> with the package that you want to unlock.

sudo apt-mark unhold apache2

OR

Use the command below for aptitude,:

sudo aptitude unhold <package-name>

Replace <package-name> with the package that you want to unlock.

sudo aptitude unhold apache2

Option 2 : Hold / Lock Packages Using Synaptic Package Manager

Synaptic package manager is a GUI frontend interface to the apt package manager. To install it on your Ubuntu, run the command below:

$ sudo apt install synaptic

If you already have Synaptic Package Manager in your Ubuntu then you can skip step above.

To launch Synaptic Package Manager, go to Activities and Search for Synaptic.

After open Synaptic Package Manager, click on the search button and type the package name that you want to lock or hold.

After find the package, select it and go to the Package tab and choose the Lock Version option as show in below image:

lock package Using Synaptic Package Manager

That’s all.

If you face any error and issue in above steps , please use comment box below to report.

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top