Cyberithub

How to Prevent Updating a Specific Package in Linux(Ubuntu/Debian)

Advertisements

In this article, we will see how to prevent a specific package from update in Linux. Many times you might have noticed that whenever you run update in your Linux system then it will sync all the installed packages with the latest available stable version from the Repo. While most of the time this is what you want but sometimes you might not want to update all the packages due to a critical application version requirement.

If you are running some critical application which requires to be of a specific version then updating the Server will create a problem as it will update that critical application as well along with all the packages. So to avoid this kind of unexpected situation, it is necessary to skip those critical applications from any package update. Here we will discuss some of the important methods in below section through which you can do that.

How to Prevent Updating a Specific Package in Linux(Ubuntu/Debian)

How to Prevent Updating a Specific Package in Linux

There are multiple ways you can use to prevent a specific package from update. Here we will see three easy and best methods to achieve that goal.

Method 1: Using apt-mark command

If you are using latest Ubuntu/Debian System where apt-mark utility is available then you can use it to set hold on a package which you don't want to update. Let's take an example of wget package. Here we are setting hold on wget package by using apt-mark hold wget command as shown below.

NOTE:

Please note that here I am using root user to run all the below commands. You can use any user with sudo access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo access to the User.
root@debian:~# apt-mark hold wget
wget set on hold.

You can check if the hold is set using apt-mark showhold command as shown below.

root@debian:~# apt-mark showhold
wget

Now if you run update in your System then you can notice that it will not update the wget package. You can also remove the hold from wget package by using apt-mark unhold wget command as shown below.

root@debian:~# apt-mark unhold wget 
Canceled hold on wget.

 

Method 2: Using aptitude command

Another method that you can use is through aptitude command. If you have aptitude tool installed in your System then you can also use this utility to set a hold on a package which will further prevent that package from any update.

NOTE:

Please note that if you don't have aptitude package installed in your System then you can install it by using apt install aptitude or apt-get install aptitude command.
root@debian:~# aptitude hold wget

If you want to remove the hold from that package then you need to use aptitude unhold wget command as shown below.

root@debian:~# aptitude unhold wget

 

Method 3: Using Synaptic Package Manager

Last method that you can use is through Synaptic Package Manager. If you have Synaptic Package Manager installed in your System then you need to first open it and then search the package(in our case it is wget package) which you want to lock. Select that package and then go to Package->Lock Version option. Here you need to tick the check box to lock that specific package as you can see below. That's it. It is done !!

NOTE:

Please note that if you don't have Synaptic Package Manager installed in your System then you can install it by using apt install synaptic or apt-get install synaptic command.

How to Prevent Updating a Specific Package in Linux(Ubuntu/Debian) 2

Similarly if you want to remove the lock from a package then you need to go to same option and just untick the Lock Version check box after selecting the specific package. This will remove the lock from that package. More about Synaptic Package Manager.

Leave a Comment