In some cases, you may not want to update a particular package. For instance, you have an Nginx web server configured with specific settings and you know updating will change its configuration and stop it from working. You can set up a package hold so that it won’t be updated even when updates are available until you’re ready to update it. Preventing a package from being installed or updated is known as “package holding“. This is a great feature in that you’re not automatically bound to update a package or software you don’t want to update in the meantime. You can also update at a later date. To get started with locking or holding packages in Ubuntu, follow the steps below:

Show held packages

There are many tools available to lock or prevent packages from updating. You can install and use Synaptic package management, and Aptitude to hold packages or use the command to do the same. Using the command line, to show all packages that are being held back from updates, run the commands below: That will list packages that are on hold.

Hold or lock packages

Now that you know how to show locked packages, use the commands below to lock or prevent specific packages from updating. If using aptitude, use the commands below: Replace with the package you want to hold back. For example, if you want to hold back the Nginx web server, run the commands below: That will hold back the Nginx web server from updating.

Unlock packages

If you want to unfreeze or unlock packages and have them continue to get updates, run the commands below: If you’re using aptitude, run the commands below: Again, replace with the package you want to unlock or unfreeze and have them continue to get updates. For example, if you want to unlock Nginx after you locked it above, run the commands below:

Synaptic package management

If you are using Synaptic package management, then go to Synaptic Package Manager (Activities ==> Search for Synaptic). Click the search button and type the package name you want to lock. When you find the package, select it and go to the Package menu and select Lock Version. That will lock the package from receiving updates. That should do it! Conclusion: This post showed you how to set up Ubuntu to lock packages and prevent them from installing or receiving updates. If you find any error above, please use the form below to report.