119

Recently, I needed to get a list of packages that were installed on my Ubuntu system which were also put on hold for upgrade.

The 'hold' status for a package means that when the operating system is upgraded, the installer will not upgrade these packages either, unless explicitly stated in the options.

I am looking for a command-line solution but understand this may be possible from the GUI as well.

Anwar
  • 77,855
pmagunia
  • 1,702
  • 2
  • 13
  • 14

5 Answers5

149

You can use apt-mark:

apt-mark showhold

this will show the packages that are kept in "hold" state so that the pacakge manager won't auto upgrade the packages.

From man apt-mark:

showhold
           showhold is used to print a list of packages on hold
heemayl
  • 93,925
28

Use dpkg

dpkg -l | grep "^hi"

The -l means to list all packages which are then piped into grep.

The regular expression "^hi" means to search for all lines that begin with "hi" which are initials for "hold" and "installed".

By default, dpkg -l will list the status, package name, version, architecture, and a short description.

pmagunia
  • 1,702
  • 2
  • 13
  • 14
8

as an alternative you can also use dpkg --get-selections:

dpkg --get-selections | grep "\<hold$"

dpkg --get-selections lists the status of all installed packages and grep "\<hold$" only shows lines which end with the word "hold".

perhaps also interesting, if you are looking for irregularities - especially if the above shows nothing (useful), would be

dpkg --get-selections | grep --invert-match "\<install$"

this shows all lines/packages which are not just installed.

DJCrashdummy
  • 1,922
4

In apt-mark versions > 2.4 you have to use the following command:

apt-mark showhold

Also it is an old tool aptitude does a fine job on the command line and you can easily surf through the hold packages:

aptitude

Type u to update packages and then press g and you will see the held back packages.

abu_bua
  • 11,313
3

And to unhold all held packages, use

sudo apt-mark unhold $(apt-mark showhold)

xpt
  • 1,197