Skip site navigation (1)Skip section navigation (2)

FreeBSD Man Pages

Man Page or Keyword Search:
Man Architecture
Apropos Keyword Search (all sections) Output format
home | help
PKGDB(1)                FreeBSD General Commands Manual               PKGDB(1)

     pkgdb, pkg_which - tools to manage and search the package database

     pkgdb [-ahfFQQquv] [-o pkgname] [-s /old/new/]
     pkg_which [-hQQq] [-c pkgname] [file] ...

     The pkgdb command is a tool to create or update the system package
     database which is used by the portupgrade(1) tool suite.  It maintains a
     hash that maps an installed file to a pacakge name, a hash that maps a
     package to an origin, and a list of installed packages.

     pkg_which looks in the package database to tell which package each
     specified file came from.  If the database is outdated but you do not
     have permission to update it, it delegates tasks to pkg_info(1).

     Actually, pkgdb and pkg_which are the same command, and are equivalent.

     The pkgdb command also works as an interactive tool for fixing the
     package registry database when -F is specified.  It helps you resolve
     stale dependencies, unlink cyclic dependencies, complete stale or missing
     origins and remove duplicates.  You should run this command periodically
     so portupgrade(1) and other pkg_* tools can work effectively and

     The following command line arguments are supported:

     file          Inquire which package file came from.  If the file is not
                   present, pkg_which calls which(1) to search PATH for the

     --help        Show help and exit.

     --auto        Turn on automatic mode when -F is also specified.  pkgdb
                   only fixes discrepancies that can be fixed securely and
                   leaves the others.

     --autofix     Shorthand of --auto --fix (-aF).

     -c PKGNAME
     --collate PKGNAME
                   Show files installed by the given packge that have been
                   overwritten by other packages.

     --force       Force; Specified with -u, update database regardless of
                   timestamps.  Specified with -F, fix "held" packages too.

     --fix         Interactively fix the package registry database.

     -o PKGNAME
     --origin PKGNAME
                   Look up the origin of the given package in the package

     --quiet       Do not write anything to stdout.  Specified twice, do not
                   write anything to stderr either.  This is for internal use.

     --noconfig    Do not read the configuration file -

     -s /OLD/NEW/
     --substitute /OLD/NEW/
                   Substitute all the dependencies recorded as OLD with NEW
                   and exit.

     --update      Update or create the package database file pkgdb.db in
                   $PKG_DBDIR, which is /var/db/pkg by default.

                   Note: if the ports database files are stale, pkgdb will
                   automatically update them before proceding, so manual
                   updating is not mandatory.

     --verbose     Turn on verbose output.

     +o   Get a list of files under /usr/local and /usr/X11R6 that do not
         belong to any package:

               find /usr/local /usr/X11R6 -type f | xargs pkg_which -v | fgrep

         As you see, you can omit version numbers.  If multiple versions are
         installed, each of them is upgraded unless they share a port origin.

     PKG_DBDIR      Alternative location for the installed package database.
                    Default is ``/var/db/pkg''.

     PORTSDIR       Alternative location for the ports tree.  Default is

     PORTS_INDEX    Alternative location for the ports INDEX file.  Default is

     PORTS_DBDIR    Alternative location for the ports database files.
                    Default is ``$PORTSDIR''.  The database files in the
                    directory are automatically created or updated as
                    necessary.  See portsdb(1) for details.

     PKGTOOLS_CONF  Configuration file for the pkgtools suite.  Default is

     /var/db/pkg                Default location of the package database.

     $PREFIX/etc/pkgtools.conf  Default location of the pkgtools configuration

     portsclean(1), portsdb(1), portupgrade(1), pkgtools.conf(5), ports(7)

     The idea of pkgdb.db was taken from NetBSD.

     Akinori MUSHA <>

     Sometimes a database may get corrupt, and the pkgtools commands will then
     to abort due with a segmentation fault.  In such cases, run ``pkgdb -fu''
     to rebuild the database, and the problems should go away.

FreeBSD                       September 22, 2001                       FreeBSD


Want to link to this manual page? Use this URL:

home | help