This brief tutorial shows students and new users how to set up Ubuntu to hold or prevent packages from updating.
In some cases, you may not want to update a particular package. For instance, you have a 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 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. 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 Synaptic package management and Aptitude to hold packages or 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:
sudo apt-mark showhold
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.
sudo apt-mark hold <package-name>
If using Aptitude, use the commands below:
sudo aptitude hold <package-name>
Replace <package-name> with the package you want to hold back. For example, if you want to hold back the Nginx web server, run the commands below:
sudo apt-mark hold nginx
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:
sudo apt-mark unhold <package-name>
If you’re using Aptitude, run the commands below:
sudo aptitude unhold <package-name>
Again, replace <package-name> 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:
sudo apt-mark unhold nginx
Synaptic package management
If you use Synaptic package management, 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, 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.
Leave a Reply Cancel reply