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.)
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:Note that it's quite fragile, as it makes assumptions about the output of
apt-cache policy
, which might change across versions...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.
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.
This script lists packages that are installed and available in the PPA:
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.
If you have a system without a Wayland/X server (like a Raspberry Pi), the answers of andrewsomething and lovinglinux cannot be used. The answer of jarno limits the use case to PPAs only, although the question is of general interest. The scripts from Riccardo Murri and Graham Dunn are quite slow due to the repeated
apt-cache policy
calls (like about 10 minutes runtime).So this is my call solving the general case on a shell being a lot faster (like less than 10 seconds runtime)
apt list --installed
gets a list of all installed packages ignoring apt's message about possible future format changes with2> /dev/null
and extracting only the package names withcut
by using/
as a delimiter with-d/
and returning the first field with-f1
.Then,
apt-cache policy
is used to get more information about all the packages. This could be executed with xargs, asapt-cache
expects its input as command line argument. As this is the remaining performance-critical part, GNUparallel
from packageparallel
is used instead to run multipleapt-cache
processes in parallel looking up 200 packages with each using-n200
. Note, that xargs can run multiple commands in parallel, too, but synchronizes output on newline, which is not correct here in general.Finally,
apt-cache
's output is parsed withrg
from packageripgrep
which is a very fast and multiline capablegrep
successor with-U
allowing to output two regular expression capture groups with-or '$1 $2'
. The regular expression captures the package name with^(\S+)
, skips to the last star marking the installed repository with[\s\S]+?\*
, then skips three words with(?:\S+\s+){3}
and finally captures the repository with(\S+)
.Something like this Python script should find all non-Ubuntu packages installed on your machine:
On my machine this took under 5 seconds to run, compared to over 8 minutes for the current top answer (from Riccardo/Pablo). Output is in the format:
You could then add an additional
and package.candidate.origins[0].site == "[ppa-domain.com]"
after the.origin != "Ubuntu"
if you only want ones from a particular ppa.