Ubuntu – Find what packages are installed from a repository

aptcommand linesearch

I'm trying to find what packages I have installed from a repository using terminal commands.

I found a post somewhere saying I could use aptitude search "?origin (<repository>) ?installed", but I couldn't get it working. I tried searching for a packages that came from ppa:ubuntu-wine/ppa and got nothing with these:

aptitude search "?origin (http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu/) ?installed"
aptitude search "?origin (http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu/) ?installed"
aptitude search "?origin (http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu/ raring/main) ?installed"

It would be nice if I could get something that works with PPAs.

Best Answer

In brackets, you should use only the name of the repository, not the URI or something else. For example in your case:

aptitude search "?origin (ubuntu-wine) ?installed"

Run apt-cache policy to see the repositories and the names (aka origin, o) of those:

$ apt-cache policy | grep wine
 500 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial/main i386 Packages
     release v=16.04,o=LP-PPA-ubuntu-wine,a=xenial,n=xenial,l=Wine Team PPA,c=main,b=i386
 500 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial/main amd64 Packages
     release v=16.04,o=LP-PPA-ubuntu-wine,a=xenial,n=xenial,l=Wine Team PPA,c=main,b=amd64

Since the search string is a regex pattern matched anywhere in the string, you can use a convenient substring like ubuntu-wine, or even just wine.

See also: How can I get a list of all repositories and PPAs from the command line into an install script?