I'd like to retrieve a list of installed packages that have no install candidate (e.g., because I removed an apt source file entry). How would I do that on Debian-based systems?

  • You could use apt-show-versions and grep for No available version in archive. – Faheem Mitha Jan 21 '12 at 15:31

With Aptitude, search for the ?obsolete pattern, possibly with a custom display format.

aptitude -F '%p' search '?obsolete'
  • I knew I should have started learning command-line package management using aptitude instead of apt. Thanks, straightforward and faster than the other answer. :) – htorque Jan 21 '12 at 17:09

This one was updated:

for package in $(dpkg -l | awk '/ii/{print $2}'); do
     if ! grep -xq "Package: $package" /var/lib/apt/lists/*Packages; then
         echo $package

Using apt-cache policy:

for package in $(dpkg -l | awk '/ii/{print $2}'); do
    if ! apt-cache policy $package | grep -q '[0-9] http://'; then
        echo $package
  • Unfortunately this doesn't seem to care about :i386 packages on systems with multiarch support. Parsing the output of apt-cache policy <package> would work, but that would be rather slow I imagine. – htorque Jan 21 '12 at 9:59
  • Give me an example of what the output of apt-cache policy would look like on your multiarch system. – Teresa e Junior Jan 21 '12 at 10:04
  • The example for such a package with no install candidate... – Teresa e Junior Jan 21 '12 at 10:07
  • paste.ubuntu.com/811658 - but I got another idea: trying to apt-get download -s all installed packages. – htorque Jan 21 '12 at 10:08
  • Your apt-cache policy doesn't help and apt-get download doesn't exist in Debian. – Teresa e Junior Jan 21 '12 at 10:24

Just update your packages with

sudo apt-get install update

In most cases it will solve the issues.If any unmet dependency issues are arises use this one

sudo apt-get -f install

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.