How to Lock Ubuntu Packages and Prevent Them from Updating

There are a few cases when you may want to freeze an Ubuntu package to a particular version. Reasons could range from a regression in upcoming version to requirement of a specific version of a package for development purposes. Thankfully, there are some easy ways to temporarily lock Ubuntu packages and prevent them from updating. This article will list some of the most common methods used to hold packages.

Using Synaptic Package Manager GUI App

Synaptic package manager is a graphical frontend to the apt package manager. It has almost full feature parity with its command line counterpart, while being pretty easy to use and straightforward. It also provides numerous filters for clean categorization of packages.

It is possible to freeze packages using Synaptic package manager. To install it in Ubuntu, run the command below:

$ sudo apt install synaptic

Many Ubuntu users prefer to downgrade a package to a specific version before locking it. So, let’s first look at the downgrading process. A package can be downgraded to an earlier version if multiple builds of it exists on Ubuntu’s server. Some packages never receive updates throughout the support period of a specific Ubuntu version, so not all packages can be downgraded.

The figure below shows how to downgrade Firefox to an earlier version using Synaptic package manager. After launching Synaptic form application launcher, search for your desired package name and click on it to highlight it. Click on “Package” > “Force Version…” to begin the downgrading process. As stated earlier, not all packages support downgrading, so “Force Version…” option may be greyed out in these cases.

In the next window, select the older version of Firefox to downgrade it. Click on “Apply” button on the toolbar to initiate the downgrading process. You will see a new window popup that will ask for your confirmation, just follow the on-screen instructions to finish the downgrading process.

Now to actually lock a package, you have to follow a similar process as above. Click on your desired package and then go to “Package” dropdown menu. Click on “Lock Version” to prevent it from updating in future. Unlike downgrading, any package can be locked.

A locked package will have a checkbox in front of it with a small lock icon to indicate that it has been frozen.

To see all locked packages on your system, click on “Status” > “Pinned”.

The same process can be followed to unlock a package. You just have to click on “Lock Version” again.

Using Apt Package Manager

Apt package manager is the default package manager shipped with Ubuntu. If you are using Ubuntu, chances are that you may have already used it to run some package management commands.

Using apt, you can run the command mentioned below to see all packages that are locked or being held.

$ sudo apt-mark showhold

To lock a specific package, run a command in the following format:

$ sudo apt-mark hold package-name

So, to lock firefox package, the command would be:

$ sudo apt-mark hold firefox

If you again run “showhold” command mentioned above, firefox will be listed in terminal as a locked package.

To unhold a package, run a command in the following format:

$ sudo apt-mark unhold package-name

For the firefox package locked using the command above, the appropriate command to unhold would be:

$ sudo apt-mark unhold firefox

Using Aptitude Package Manager

Aptitude package manager is a newer package manager based on apt. It is simple to use and provides some handy extra options over apt, along with a terminal based frontend to easily manage packages.

To install Aptitude in Ubuntu, you have to run the command below:

$ sudo apt install aptitude

The aptitude package manager has similar command pattern to apt. Command to hold a package is (replace package-name):

$ sudo aptitude hold package-name

Command to unhold a package is (replace package-name):

$ sudo aptitude unhold package-name

To see all held packages using the aptitude package manager, run command:

$ sudo aptitude search ‘~i’ | grep "ih "

Using Dpkg

Dpkg is a simple utility to manage installation and uninstallation of debian software packages. Just like apt package manager, it can be used to lock packages with some straightforward commands.

To lock a package using dpkg, run a command in the following format (replace package-name):

$ echo "package-name hold" | sudo dpkg –set-selections

To unlock a package, run command (replace package-name):

$ echo "package-name install" | sudo dpkg –set-selections

To see all packages locked by dpkg, run command:

$ dpkg –get-selections | grep hold

To check if a particular package has been locked or not, run command (replace package-name):

$ dpkg –get-selections | grep package-name


These are a few methods that you can use to lock packages in Ubuntu. Unless you really want a specific version of package, locking and downgrading should be avoided, especially for packages that need regular security updates like web browsers and the Linux kernel.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Best Ubuntu Flavors

Unlike Windows, Ubuntu is much more sophisticated with various flavors to appeal to different types of users. Before discussing...

How to Keep Ubuntu 17.10 up to Date

When you install Ubuntu from a ISO image, the operating system is not up to date. Because the ISO is not updated on the official...

How to install Cerebro Search on Ubuntu 17.04 and Below

I recently came across a simple but yet powerful search app called – Cerebro Search. Cerebro is an open-source search...
Bài Viết

Bài Viết Mới Cập Nhật


Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail

Mua shadowsocks và hướng dẫn sữ dụng trên window

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo