In Ubuntu Linux, how do I list packages installed from the “universe” repository?

Solution 1:

Okay, I figured out how to do this:

aptitude search "~i" -F "%s# %p"

Which of course can easily be grepped to find items from the “universe” repository:

aptitude search "~i" -F "%s# %p" | grep universe

Solution 2:

You can provide a custom format for the output of the dpkg command (using the -f option). Try something like this, using the Origin variable:

dpkg-query -f='${Package} ${Version}\t${Origin}\n' --get-selections

There's more info on the formatting argument on this page: http://www.tin.org/bin/man.cgi?section=1&topic=dpkg-query

The default format string is "${Package}\t${Version}\n". Actu- ally, all other fields found in the status file (i.e. user defined fields) can be requested, too. They will be printed as- is, though, no conversion nor error checking is done on them. To get the name of the dpkg maintainer and the installed ver- sion, you could run:

dpkg-query -W -f='${Package} ${Version}\t${Maintainer}\n' dpkg

Solution 3:

I tried aptitude search ~i -F "%s# %p"

in ubuntu 12.04 and 14.04 but it didn't show repositories.

So I wrote this small script:

# more origins.sh
#!/bin/bash
for i in $(dpkg -l |grep ^ii |awk -F' ' '{print $2}'); do
  apt-cache showpkg "$i"|head -3|grep -v '^Versions'|cut -d'(' -f2|cut -d')' -f1|sed -e 's/^Package: //;' | paste -d '\t' - -
done

Then

bash origins.sh|grep universe