• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

List of all installed ports without dependencies


New Member

Messages: 2

Greetings all. My English is not very good, excuse me if I said something wrong.

I'm a gentoo user and a novice in FreeBSD. In gentoo I can find list of all installed packages in world file, but I can't find nothing similar in FreeBSD. All the ways I could find (portmaster, pkg etc...) lists absolutely all packages, it does not matter whether they are dependencies or not.

Is there any way to list all installed packages? Installed I mean as installed, not built as a dependency. For example if I installed mtr and tcpdump on clean system, I would to see only mtr and tcpdump in this list, even if lot of dependencies installed with above two packages. It is possible in FreeBSD?

Thanks for attention.



Thanks: 1,222
Messages: 1,812

Try pkg prime-list

P.S. Welcome! And don't worry your English is fine.

A word of warning about using port origins for this.

With flavors in the ports tree there is no longer a 1:1 correspondence between packages and port origins. If you give pkg install an origin instead of a package name it will install all packages (all flavors) from that origin.

If you use the origin list to replicate your setup later you might end up with more packages than were actually installed when generating the list.

To prevent that use a list of package names which can be generated with pkg prime-list (which is an alias for pkg query -e '%a = 0' '%n').


New Member

Messages: 2

Wow! So fast, I didn't expect... :)
Thank you very much, pkg prime-origins and pkg prime-list is exactly what I need. But I can't find nothing about above options in pkg manual page (in my system at least).

Thanks again!


Staff member

Thanks: 5,628
Messages: 25,958

But I can't find nothing about above options in pkg manual page (in my system at least).
They are actually aliases for specific pkg-query(8) commands. Have a look in /usr/local/etc/pkg.conf:
ALIAS              : {
  all-depends: query %dn-%dv,
  annotations: info -A,
  build-depends: info -qd,
  cinfo: info -Cx,
  comment: query -i "%c",
  csearch: search -Cx,
  desc: query -i "%e",
  download: fetch,
  iinfo: info -ix,
  isearch: search -ix,
  prime-list: "query -e '%a = 0' '%n'",
  prime-origins: "query -e '%a = 0' '%o'",
  leaf: "query -e '%#r == 0' '%n-%v'",
  list: info -ql,
  noauto = "query -e '%a == 0' '%n-%v'",
  options: query -i "%n - %Ok: %Ov",
  origin: info -qo,
  provided-depends: info -qb,
  raw: info -R,
  required-depends: info -qr,
  roptions: rquery -i "%n - %Ok: %Ov",
  shared-depends: info -qB,
  show: info -f -k,
  size: info -sq,


Staff member

Thanks: 1,048
Messages: 3,848

$ pkg help prime-origins
`prime-origins` is an alias to `query -e '%a = 0' '%o'`

$ pkg help prime-list
`prime-list` is an alias to `query -e '%a = 0' '%n'`
There might be something about them listed in the pkg-query(8) man page. Ah, yes, there is, but it's not obvious:
List non-automatic packages:
$ pkg query -e '%a = 0' %o
Someone may want to add a bug report asking for "prime-origins" and "prime-list" to be added to the man page.

Edit: Oh! Looks like SirDice beat me to it, and found the full list of aliases. :) And there's even a man page for them: pkg-alias(8) You can view the list like so:
$ pkg alias
ALIAS                ARGUMENTS
all-depends          'query %dn-%dv'
annotations          'info -A'
build-depends        'info -qd'
cinfo                'info -Cx'
comment              'query -i "%c"'
csearch              'search -Cx'
desc                 'query -i "%e"'
download             'fetch'
iinfo                'info -ix'
isearch              'search -ix'
prime-list           'query -e '%a = 0' '%n''
prime-origins        'query -e '%a = 0' '%o''
leaf                 'query -e '%#r == 0' '%n-%v''
list                 'info -ql'
noauto               'query -e '%a == 0' '%n-%v''
options              'query -i "%n - %Ok: %Ov"'
origin               'info -qo'
provided-depends     'info -qb'
raw                  'info -R'
required-depends     'info -qr'
roptions             'rquery -i "%n - %Ok: %Ov"'
shared-depends       'info -qB'
show                 'info -f -k'
size                 'info -sq'


Aspiring Daemon

Thanks: 111
Messages: 796

Is there any way to list all installed packages? Installed I mean as installed, not built as a dependency.
I know you mentioned ports-mgmt/portmasterearlier but I always found it had a use that I really like. The command portmaster -L lists all the ports installed (which I know you do not want to see) but it categorizes into the type of port; i.e root port, trunk port, leaf port, etc. Its a really fast way to see. The -L flag option also lists which need to be upgraded, based on your current ports tree. The -l (lower case L) option does not list the upgrades that are available. Just though I would throw that out there.


Well-Known Member

Thanks: 152
Messages: 266

You could also try pkg leaf if you don't mind about port origin.