RackNerd Billboard Banner

How To Prevent A Package From Being Automatically Installed, Upgraded Or Removed In Ubuntu

Ever had Ubuntu upgrade or remove a package you rely on? Or maybe you want to lock in a specific version for stability? Whatever your reason, Ubuntu makes it easy to “hold” packages—so they stay just the way you want them.

Here’s how to stop Ubuntu from automatically installing, upgrading, or removing specific packages.


Why Hold a Package?

Sometimes, you need to prevent a package from changing:

  • You depend on a specific version for your workflow.
  • A newer update breaks compatibility with your software.
  • You want to avoid auto-removal of critical tools.

Whatever the reason, the solution is simple: put the package on hold.


Step 1: Open Your Terminal

All these commands work in the terminal. Open it using Ctrl + Alt + T or search for “Terminal” in your app menu.


Step 2: Find the Package Name

First, you need to know the exact package name. For example, let’s use firefox. You can search for installed packages with:

dpkg --list | grep firefox

Replace firefox with your actual package.


Step 3: Put the Package On Hold

Use the apt-mark tool to hold the package:

sudo apt-mark hold package-name

For example:

sudo apt-mark hold firefox

This command tells Ubuntu NOT to upgrade or remove this package automatically.


Step 4: Check If the Hold Worked

Verify the status with:

apt-mark showhold

If your package is listed, it’s on hold and won’t be touched during upgrades.


Step 5: Remove the Hold (When You’re Ready)

To let Ubuntu manage the package again, simply unhold it:

sudo apt-mark unhold package-name

Example:

sudo apt-mark unhold firefox

Pro Tip: Protect Multiple Packages

You can hold more than one package at a time by listing them all:

sudo apt-mark hold package1 package2 package3

Summary Table

TaskCommand
Hold a packagesudo apt-mark hold package-name
Unhold a packagesudo apt-mark unhold package-name
Show held packagesapt-mark showhold

Final Thoughts

Locking packages is a simple, effective way to control what happens on your Ubuntu system. Remember: held packages won’t update or get removed automatically—so unhold them when you’re ready to receive new updates.

Got questions? Leave a comment below!

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
RackNerd Billboard Banner
© 2025 Computer Everywhere
Your Everyday Guide to the Digital World.
Terms of Service | Privacy Policy
Copy link