How to prevent a package from being updated in Debian

If you want to update all the packages other than one in your debian server follow this procedure

There are three ways of holding back packages, with dpkg, aptitude or with dselect.

Using dpkg

Put a package on hold

echo “package hold” | dpkg --set-selections


echo “apache2 hold” | dpkg --set-selections

Remove the hold

echo “package install” | dpkg --set-selections


echo “apache2 install” | dpkg --set-selections

Knowing the status of your packages

dpkg --set-selections

Using aptitude

With aptitude, you can hold a package using

#aptitude hold package_name


#aptitude hold apache2

and remove the hold with

aptitude unhold package_name


#aptitude unhold apache2

Using dselect

With dselect, you just have to enter the [S]elect screen, find the package you wish to hold in its present state, and press the `=’ key (or `H’). The changes will go live immediately after you exit the [S]elect screen.

Sponsored Link

3 thoughts on “How to prevent a package from being updated in Debian

  1. there’s also the dpkg-hold, dpkg-unhold, dpkg-purge, and dpkg-remove scripts in the dlocate package.

    they’re trivial wrapper scripts for the ‘echo “package hold” | dpkg –set-selections’ method mentioned above.

    dpkg-unhold is a bit of a misnomer. it actually flags the package for installation. if it was held, it’s now unheld. if it wasn’t, it’s now marked for installation in the next apt-get/aptitude/whatever upgrade.

    disclaimer: i’m the author and debian maintainer for dlocate. i wrote the dpkg-hold etc scripts a long time ago, so i still use them. aptitude hold/unhold are probably a better choice for people who aren’t already used to my scripts.

  2. >> Knowing the status of your packages
    >> dpkg –set-selections
    dpkg –get-selections

Leave a comment

Your email address will not be published. Required fields are marked *