How to hold or lock Packages in Ubuntu Linux

|

|

The tutorial guides new Ubuntu users on how to set up package holding, a feature that prevents specific packages from automatic updates. It contains commands for showing held packages and locking/unlocking specific ones using commands or Synaptic package management. Therefore, users can choose when to update their software without affecting preconfigured settings.

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 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 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.


Discover more from Geek Rewind

Subscribe to get the latest posts to your email.

Like this:



One response to “How to hold or lock Packages in Ubuntu Linux”

  1. Kevin Lausen Avatar
    Kevin Lausen

    Also of note:
    If you have a package you are actively using, and don’t want it removed|auto-removed;
    then holding a package works there to.
    In my case my system wanted to remove tmux, b/c it was a dependency of byobu;
    but I’ve switched to just tmux since then.
    I should probably un-hold & re-install, but I’ll do that when I don’t have multiple sessions going.

Leave a Reply

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

Blog at WordPress.com.

Discover more from Geek Rewind

Subscribe now to keep reading and get access to the full archive.

Continue reading