How can I list all packages I've installed from a particular repository?

How can I list all installed packages that are not available from the main Ubuntu archives, and also see which repositories they came from? (If I knew the answer to this question, I could grep that list for a particular PPA name to find out the answer to my first question.)

  • Since there doesn't seem to be an existing command-line tool for this (sadly), I'll accept one of the GUI answers. – Marius Gedminas Oct 15 '10 at 0:07
up vote 24 down vote accepted

Expand the "Installed Software" item in Ubuntu Software Center. You'll see a list of all the different repositories that you've enabled. Clicking on the repo will show you the packages you've installed from each.

alt text

  • I'm afraid that option is only available in Ubuntu 10.10 or am I missing something? My Software Center doesn't display sources below that menu. – lovinglinux Oct 11 '10 at 15:17
  • 2
    In my version I have an "Installed" dropdown at the top. When I select that option, I can choose the various sources (core, for purchse, PPA...) – Alexis Wilke Oct 29 '14 at 6:06
  • In Ubuntu 16.04, this page is no longer available. However, synaptic has a similar feature -- click "Origin" in the bottom-left. – Josh Apr 9 '17 at 8:48

There seems to be no record of the origin of an installed package.

If you are fine with getting the location from whence a package of the same name would be downloaded from, this is available through apt-cache policy. The following (rather ugly) script does the trick for me:

LC_ALL=C dpkg-query --showformat='${Package}:${Status}\n' -W '*' \
  | fgrep ':install ok installed' \
  | cut -d: -f1 \
  | (while read pkg; do 
       inst_version=$(apt-cache policy $pkg \
                                | fgrep Installed: \
                                | awk '{ print $2 }'); 
       origin=$(apt-cache policy "$pkg" \
                          | fgrep " *** ${inst_version}" -C1 \
                          | tail -n 1 \
                          | cut -c12-); 
       echo $pkg $origin; 
     done)

Note that it's quite fragile, as it makes assumptions about the output of apt-cache policy, which might change across versions...

  • Yeah, this would basically mean writing a tool from scratch. And I think parsing /var/lib/apt/lists with Perl or Python would be faster and more robust. – Marius Gedminas Oct 15 '10 at 0:07
  • Works normally here, in 2018 :) Thank you! – N0rbert Mar 5 at 7:25
  • I developed a similar solution tested on Ubuntu and Debian. – famzah Apr 24 at 18:23

Open Synaptic Package Manager and click the "Origin" button on the bottom of the left sidebar. It will list your sources. Select a source to see the available/installed packages.

This script lists packages that are installed and available in the PPA:

#!/bin/sh
# Give PPA name as an argument, e.g. ppa:oibaf/graphics-drivers

name1="$(echo "$1"|cut -d: -f2|cut -d/ -f1)"
name2="$(echo "$1"|cut -d/ -f2)"

awk '$1 == "Package:" { if (a[$2]++ == 0) print $2; }' \
/var/lib/apt/lists/*"$name1"*"$name2"*Packages |
xargs dpkg-query -W -f='${Status} ${Package}\n' 2>/dev/null  | awk '/^[^ ]+ ok installed/{print $4}'

I applied this.

BTW As for removing PPA from use, use ppa-purge program; I have created an improved version of it here.

Under Quantal (12.10), the space in the origin line needs to be removed.

LC_ALL=C dpkg-query --showformat='${Package}:${Status}\n' -W '*' \
 | fgrep ':install ok installed' \
 | cut -d: -f1 \
 | (while read pkg; do 
   inst_version=$(apt-cache policy $pkg \
                            | fgrep Installed: \
                            | cut -d: -f2-); 
   origin=$(apt-cache policy "$pkg" \
                      | fgrep " ***${inst_version}" -C1 \
                      | tail -n 1 \
                      | cut -c12-); 
   echo $pkg $origin; 
 done)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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