Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to figure out a way to get a list of the packages that are no longer available in the repositories that I have enabled. This workstation has been through quite a few versions of Ubuntu and has had many 3rd party repositories added and removed. I'd like to get a list of software that I have from these removed repositories, so I can clean it up or add back the appropriate repositories.

share|improve this question

migrated from Jan 24 '12 at 19:43

This question came from our site for system and network administrators.

up vote 13 down vote accepted
aptitude search '~o'

Aptitude has some very powerful searching available. Unfortunately the syntax is a bit unwieldy and you have to dig past the manpage to find the documentation, but its worth it.

apt-show-versions can also be helpful:

apt-show-versions | grep 'No available version'
share|improve this answer
see a nice article about obsolete packages here:… – tictacbum Mar 8 '14 at 11:02

To get a list of apps that are not in a Registered Repository or PPA do this:

sudo apt-get install apt-show-versions
apt-show-versions | grep 'No available version'

That should output text like this:

app1 installed: No available version in archive
app23 0.3.6 installed: No available version in archive
app332 7.0.9377 installed: No available version in archive

For me this worked and showed three apps I installed using DEB packages and weren't available in a Repo or PPA.

Do remember though that it's impossible to check for all programs, only the ones that went through dpkg. For instance, some apps are installed by simply extracting them into the correct folders, or others use a standalone installer bin or script. So the best way is for you yourself to keep a list of apps you installed via any method other than APT.

share|improve this answer
Works for all my local dpkg installed packages. One exception. It lists skype-bin, whereas apt-cache policy skype-bin clearly shows the Canonical partner repo. I'm not sure what is going on. Multiarch issue? Still +1 for apt-show-versions! – gertvdijk Jan 5 '13 at 21:37
aptitude calls these 'obsolete' packages. See chronitis comment above. – Henk Poley Mar 5 '13 at 16:54

If you have aptitude installed use,

aptitude search '?obsolete'

or its short form

aptitude search '~o'

Here it is a sample output

i A gcc-4.7-base - GCC, the GNU Compiler Collection (base package)
id  libdb4.7     - Berkeley v4.7 Database Libraries [runtime]
i   libudev0     - libudev shared library

The first character of each line indicates the current state of the package. The most common states are:

  • p, meaning that no trace of the package exists on the system,
  • c, meaning that the package was deleted but its configuration files remain on the system,
  • i, meaning that the package is installed, and
  • v, meaning that the package is virtual.

The second character indicates the stored action to be performed on the package, if any, otherwise a blank space is displayed. The most common actions are:

  • i, meaning that the package will be installed,
  • d, meaning that the package will be deleted, and
  • p, meaning that the package and its configuration files will be removed.

If the third character is A, the package was automatically installed.

For a complete list of the possible state and action flags, see the section Accessing Package Information in the aptitude reference guide.

share|improve this answer
aptitude search ?obsolete may work in bash, but you should use aptitude search '?obsolete' – A.B. Jul 1 '15 at 18:28
could you add some detail on parsing the output? – Elder Geek Jul 2 '15 at 1:54
Is '?obsolete' different from '~o'? – Sean Jul 2 '15 at 18:20
@A.B. The Search patterns reference guide does not mention the use of single quotes, which should be therefore avoided. However it shows the use of the double quotes in case of spaces in the search terms, but this is not the case. – Demis Palma ツ Jul 2 '15 at 22:59
@Sean No, they are not different. ~o is the short form for ?obsolete indeed. – Demis Palma ツ Jul 2 '15 at 23:00

There may be a cleaner way, but off the top of my head you can do

dpkg -l | cut -f 3 -d ' ' > installed
xargs -n 1 --replace=X apt-cache search ^X$ < installed | cut -f 1 -d ' ' > available
diff installed available

Cleanup the first few lines of the installed file: it will have headers.

Bonus if anyone can fix my syntax highlighting...

share|improve this answer
if you are going to use the output of dpkg -l to get a list of installed packages, you should limit the results to lines with 'i' in the second column, as dpkg will also list packages which are not installed (perhaps removed but not purged). as an example, altering your first command to be dpkg -l | grep '^.[^i]' | cut -f 3 -d ' ' it would return a list of packages, which are NOT installed. (but once were) – stew Jan 24 '12 at 19:46
also, apt-cache search someinstalledpackage will return something even if the package isn't available from a repo, so I don't believe this will work at all. – stew Jan 24 '12 at 19:54
@stew I'll leave this up here to see if anybody reaches conclusions, but your answer is definitely far better. +1 to you. – Jeff Ferland Jan 24 '12 at 19:59

As mentioned apt-get search is not a good method to check if a package is still available. Additional I've added everything to just one line:

for i in `dpkg -l | grep '^i' | awk '{ print $2 }'`; do apt-cache show $i > /dev/null || echo $i; done
share|improve this answer
And why grep '^i' – A.B. Sep 22 '15 at 11:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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