I would like to remove any packages that I installed from third party repositories. I recently installed some backports from PPA repositories, and I suspect one of them broke my Ubuntu 12.04 server system.

Is there any way I can list all currently installed packages in that are not available in the repositories, or, which version is higher than the one available in the current repositories?


Two clean ways of doing this that both work the same:

sudo add-apt-repository --remove ppa:whatever/ppa


sudo ppa-purge ppa:repository-name/subdirectory
  • Will this downgrade packages that were upgraded by the PPA? Apr 19 '13 at 17:44
  • Suggest you look at the man page next time. man ppa-purge says "This script provides a bash shell script capable of automatically down‐grading all packages in a given PPA back to the ubuntu versions."
    – BullShark
    Apr 20 '13 at 20:42

First you should install and use deborphan. This will find libraries and things that are no longer required.

Aptitude can find obsolete packages with aptitude search '~o'

My pre-aptitude command for doing this is below. But this shows some false positives when I just tested on a multiarch setup.

# the one-line command
diff -u <(dpkg --get-selections | awk ' {print "Package: " $1}' | sort -u) \
        <(zcat /var/lib/apt/lists/*_Packages.gz | grep 'Package: ' | sort -u) \
  | egrep '^\-'

#  breaking it down down with some comments

#  See all the installed packages
# dpkg --get-selections | awk ' {print "Package: " $1}' | sort -u

#  see all the available packages
# zcat /var/lib/apt/lists/*_Packages.gz | grep 'Package: ' | sort -u

#  compare and find the installed that are no longer available.
# diff -u <( installed ) <( available ) | egrep '^\-'
  • Thanks. I removed some packages but didn't fix the problem. Any idea as to detect installed backports? I.e. where the installed version is higher than the current repository version? Mar 15 '13 at 4:13

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.