36

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.

6 Answers 6

30

Here is a shell script I wrote to display packages installed from different origins excluding Ubuntu. It uses common dpkg -l output format. It works faster than aptitude solutions.

#!/bin/sh

# Print packages installed from different origins.
# Exclude standard Ubuntu repositories.

grep -H '^Origin:' /var/lib/apt/lists/*Release | grep -v ' Ubuntu$' | sort -u \
| while read -r line; do
    origin=${line#* }    
    echo $origin:
    
    list=${line%%:*}
    sed -rn 's/^Package: (.*)$/\1/p' ${list%_*Release}*Packages | sort -u \
    | xargs -r dpkg -l 2>/dev/null | grep '^.i '
    echo
 done

Some packages may be available from more than one repository. Run apt policy [pkgname] to check from which repository the current package is actually installed from.

Note that there may also be installed packages that have no such origin available, see this to find them.

4
  • 1
    This is the only script which actually worked for me. Thank you!
    – cjones26
    Commented Jul 21, 2020 at 0:20
  • I tried this script, but it also listed Ubuntu packages. Any idea why? Commented Nov 9, 2020 at 11:30
  • @technastic_tc Could you run the line starting by grep excluding ``. Upload the result in pastebin and share the link to it.
    – jarno
    Commented Nov 9, 2020 at 18:14
  • @jarno chat.stackexchange.com/rooms/116028/… Commented Nov 10, 2020 at 6:30
23

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?

3
  • This did not list packages for me: aptitude search "?origin (multiverse) ?installed" - shouldn't it? ("multiverse" is enabled) Commented Apr 23, 2014 at 8:13
  • @VolkerSiegel no, but use aptitude search "?section (multiverse) ?installed", instead.
    – jarno
    Commented Apr 5, 2018 at 11:46
  • 1
    On my system, this seems to list packages that are installed and also available in the specified repository, irrespective of whether they were actually installed from that repository. Commented Mar 30, 2022 at 17:38
5

Origin is not URL of repository. To find Origin of repository look for file in /var/lib/apt/lists/ ending with Release.

For example

grep "Origin" /var/lib/apt/lists/linux.dropbox.com_debian_dists_wheezy_Release

Will show:

Origin: Dropbox.com

So aptitude search "?origin(dropbox.com) ?installed" will show me installed package from dropbox repository.

3
3

From the command line If you like to do means

awk '$1 == "Package:" { if (a[$2]++ == 0) print $2; }' /var/lib/apt/lists/*PPA-FIRST-PART*PPA-SECOND-PART*Packages

for example : All there are packages from noobslab

 jai@frank-Jai:~$ awk '$1 == "Package:" { if (a[$2]++ == 0) print $2; }' /var/lib/apt/lists/*noobslab*Packages

python-logilab-common
synapse
ubuntuone-client
python-ubuntuone-storageprotocol
ubuntuone-client-gnome
python-ubuntuone-client
lives
libweed0
libweed-dev
lives-data
converseen
minitube
libsyncdaemon-1.0-1
libsyncdaemon-1.0-dev
ubuntu-sso-client
python-ubuntuone-devtools
ubuntuone-dev-tools
ubuntuone-control-panel
python-ubuntuone-control-panel
synapse-dbg
gir1.2-syncdaemon-1.0
libweed-dbg
lives-dbg
umplayer
umplayer-translations
libgranite-dev
deepin-software-center
ubuntuone-control-panel-qt
python-dirspec
rhythmbox-ubuntuone
python-ubuntu-sso-client
ubuntu-sso-client-qt
python-ubuntu-sso-client.tests
granite-demo
ubuntuone-client-proxy
python-oauthlib
slidewall
python3-dirspec
python3-oauthlib
ubuntuone-client-data
libgranite1
libgranite1-dbg
gir1.2-granite-1.0
libgranite-common
curlew
fbmessenger
open-as-administrator
indicator-synapse
indicator-synapse-dbg
wallpaper-manager
awoken-icon-theme
malys-uniblack
malys-uniblue
malys-ex
acyl-icons
nitrux-icons
piratunbu-icons
azenis-green-icons
nouvegnome-color
nouvegnome-gray
hi-lights-icons
matrilineare
zoncolor-icons
royal-linux-icons
elementary-icons
myhumanity
myelementary
glass-icons
osx-nostalgie
sky-blue-cinnamon
sky-blue-gnome
sky-blue-unity
wine-blue-remix
lubuntubox
windows7-icons
appleart-icons
magical-lights-icons
colored-plastic-icons
numix-utouch-icon-theme
ubudao-style
artnet-icons
high-delight-icons
snow-sabre-icons
trevilla-icons
aery-icons
ambiance-blue
zukitwo
gnomishbeige-theme
salience-theme
zukiwi
gnomishgray
delorean-dark
smoothly-theme
ambiance-ds-blue
ambiance-lime
gnomishdark
zukitwo-cupertino-gs
mediterranean-theme
elementaryish
borderline
boje
wow-2
zoncolor-themes
omg-suite
simplex
leopard-steel
dorian-theme
daylight
adwaita-elements
uncomplicated
trevilla-jmhzonedark
trevilla-dark
trevilla-white
trevilla-whiteblue
trevilla-whiteorange
trevilla-white2
ambiancep-set
ambiance-crunchy
trevilla-gray
siva-series-gtk
cobibird
elegant-brit
mac-ithemes-noobslab
mac-icons-noobslab
ubuntu-touch-themes
windows8-theme
bigfootblue-cinnamon
windows8-cinnamon
eliza1-cinnamon
bigfootred-cinnamon
plus1-theme
futura
blo-theme
darkair-theme
plane-gtk3
deepin-gtk-theme
nokto-theme
numix-theme
neptune-theme
trevilla-themes
jai@frank-Jai:~$ 

Credit goes here

6
  • I got this error: bash: awk: No such file or directory Commented Sep 7, 2013 at 16:55
  • @Enkouyami whats the ls of /var/lib/apt/lists/
    – Raja G
    Commented Sep 8, 2013 at 4:11
  • Here's a link to what I got pastebin.com/AmiH9E9n Commented Sep 9, 2013 at 7:12
  • @Enkouyami oops sorry , I mean the command what you have entered
    – Raja G
    Commented Sep 9, 2013 at 7:16
  • 1
    @Enkouyami Ok this in not about command , placement. do as awk '$1 == "Package:" { if (a[$2]++ == 0) print $2; }' /var/lib/apt/lists/*haguichi*webupd8team*Packages
    – Raja G
    Commented Sep 10, 2013 at 1:54
0

Then you can use Y-PPA manager. Open your terminal and type:

sudo add-apt-repository ppa:webupd8team/y-ppa-manager
sudo apt-get update
sudo apt-get install y-ppa-manager

Then open your Unity dash and search with Y -PPA and then open the Icon.

enter image description here

Click at manage PPAs as shown in the image and then select one PPA and it will give you the details of the PPA and Its packages.

4
  • Could you provide some instructions for using Y-PPA manager?
    – Seth
    Commented Sep 7, 2013 at 4:26
  • @Seth my friend. done.
    – Raja G
    Commented Sep 7, 2013 at 4:40
  • 1
    I was looking for a command line solution. Commented Sep 7, 2013 at 16:52
  • 1
    This solution is neither command line nor answers the main question - how to list packages installed from a given repo? It only shows ALL packages available from a PPA. Commented Feb 7, 2019 at 8:54
-2

Run the following one-liner Bash shell script to list all the installed packages along with the repository names from which they are installed.

dpkg-query -f '${Package}\n' -W|while read l;do apt-cache madison $l;done
2
  • Why tail -n 796?
    – muru
    Commented May 8 at 10:44
  • @muru I had used tail to just exclude the 'dpkg -l' output title from the top. but we can directly use also query the same request from dpkg-query as I have edited the command.
    – Mr. Linux
    Commented May 16 at 5:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .