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
PKG(8)                  FreeBSD System Manager's Manual                 PKG(8)

     pkg, pkg-static - a utility for manipulating packages

     pkg [-v] [-d] [-l] [-N] [-j <jail name or id> | -c <chroot path>]
         [-C <configuration file>] [-R <repository configuration directory>]
         <command> <flags>

     provides an interface for manipulating packages - registering, adding,
     removing and upgrading of packages.  pkg-static is a statically linked
     variant of pkg typically only used for the initial installation of pkg.
     There are some differences in functionality.  See pkg.conf(5) for

     The following options are supported by pkg:

     -v      Displays the current version of pkg

     -d      Show debug information

     -l      List all the available command names, and exit without performing
             any other action.  The -v option takes precedence over -l but -l
             will override any other command line arguments.

     -N      Activation status check mode.  Prevent pkg from automatically
             creating or initializing the sqlite database in
             /var/db/pkg/local.sqlite if it does not already exist.

             Prevent pkg from performing any actions if no packages are
             currently installed, on the basis that a correctly initialised
             system using pkg will always have at least the pkg package itself

             If used without any other arguments, pkg -N will run the sanity
             tests and if successful print out a short message showing how
             many packages are currently installed.  The exit status should be
             a reliable indication of whether a system is configured to use
             pkg as its package management system or not.

             Example usage:

                     if pkg -N >/dev/null 2>&1; then
                       # pkgng-specifics
                       # pkg_install-specifics

             The -N flag was first released in the /usr/sbin/pkg bootstrapper
             in FreeBSD 8.4, but was missing from FreeBSD 9.1.  It was not
             released in pkg until 1.0.13.  Because of this, it may not be
             enough to just call pkg -N, as the bootstrapper may be invoked,
             or an error returned from pkg.  The following script is the
             safest way to detect if pkg is installed and activated:

                     if TMPDIR=/dev/null ASSUME_ALWAYS_YES=1 \
                          PACKAGESITE=file:///nonexistent \
                          pkg info -x 'pkg(-devel)?$' >/dev/null 2>&1; then
                       # pkgng-specifics
                       # pkg_install-specifics

     -j <jail name or id>
             pkg will execute in the given <jail name or id>, where name
             matches ``jls name'' and id matches ``jls jid''.  See jail(8) and

     -c <chroot path>
             pkg will chroot in the <chroot path> Environment

     -C <configuration file>
             pkg will use the specified file as a configuration file

     -R <repository configuration directory>
             pkg will search the directory for per-repository configuration
             files.  This overrides any value of REPOS_DIR specified in the
             main configuration file.

     The following commands are supported by pkg:

     help command
             Display usage information of the specified command.

     add     Install a package from either a local source or a remote one.

             When installing from remote source you need to specify the
             protocol to use when fetching the package.

             Currently supported protocols are FTP, HTTP and HTTPS.

             Add, modify or delete tag-value style annotations on packages.

     audit   Audits installed packages against known vulnerabilities.

             Delete packages which were automatically installed as
             dependencies and are not required any more.

     backup  Dump the local package database to a file specified on the

     check   Sanity checks installed packages.

     clean   Cleans the local cache of fetched remote packages.

             Convert to and from the old pkg_add(1) format.

     create  Create a package

     delete  Delete a package from the database and the system.

     fetch   Fetches packages from a remote repository.

     info    Display information about installed packages.

             Install a package from a remote package repository.  If a package
             is found in more than one remote repository, then installation
             happens from the first one.  Downloading a package is tried from
             each package repository in turn, until the package is
             successfully fetched.

     lock    Prevent modification or deletion of a package.

             List the available plugins.

     query   Query information about installed packages.

             Register a package in the database.

     repo    Create a local package repository for remote usage.

     rquery  Query information for remote repositories.

     search  Search for the given pattern in the remote package repositories.

     set     Modify information in the installed database.

     shell   Fires up a sqlite shell to the local or remote database.  Extreme
             care should be taken when using this command.

     shlib   Displays which packages link to a specific shared library.

     stats   Display package database statistics.

     unlock  Unlocks packages, allowing them to be modified or deleted

     update  Update the available remote repositories as listed in

             Displays UPDATING entries of installed packages.

             Upgrade a package to a newer version.

             Summarize installed versions of packages.

     which   Query the database for package(s) that installed a specific file.

     The list of environment variables that affect the execution of pkg is in

     See pkg.conf(5).

     Search for a package:
           $ pkg search perl

     Install a package:
           Installing must specify a unique origin or version otherwise it
           will try installing all matches.

           % pkg install perl-5.14

     List installed packages:
           $ pkg info

     Upgrade from remote repository:
           % pkg upgrade

     Change the origin for an installed package:
           % pkg set -o lang/perl5.12:lang/perl5.14
           % pkg install -Rf lang/perl5.14

     List non-automatic packages:
           $ pkg query -e '%a = 0' %o

     List automatic packages:
           $ pkg query -e '%a = 1' %o

     Delete an installed package:
           % pkg delete perl-5.14

     Remove unneeded dependencies:
           % pkg autoremove

     Change a package from automatic to non-automatic, which will prevent
     autoremove from removing it:
           % pkg set -A 0 perl-5.14

     Change a package from non-automatic to automatic, which will make
     autoremove allow it be removed once nothing depends on it:
           % pkg set -A 1 perl-5.14

     Create package file from an installed package:
           % pkg create -o /usr/ports/packages/All perl-5.14

     Determine which package installed a file:
           $ pkg which /usr/local/bin/perl

     Audit installed packages for security advisories:
           $ pkg audit

     Check installed packages for checksum mismatches:
           # pkg check -s -a

     Check for missing dependencies:
           # pkg check -d -a

     SBUF(9), elf(3), fetch(3), libarchive(3), pkg.conf(5), pkg-add(8),
     pkg-annotate(8), pkg-audit(8), pkg-autoremove(8), pkg-backup(8),
     pkg-check(8), pkg-clean(8), pkg-config(8), pkg-convert(8), pkg-create(8),
     pkg-delete(8), pkg-fetch(8), pkg-info(8), pkg-install(8), pkg-lock(8),
     pkg-query(8), pkg-register(8), pkg-repo(8), pkg-rquery(8), pkg-search(8),
     pkg-set(8), pkg-shell(8), pkg-shlib(8), pkg-stats(8), pkg-update(8),
     pkg-updating(8), pkg-upgrade(8), pkg-version(8), pkg-which(8), pthread(3)

     To build your own package set for one or multiple servers see

     The pkg command first appeared in FreeBSD 9.1.

     Baptiste Daroussin <> Julien Laffaye
     <> Philippe Pepiot <> Will Andrews
     <> Marin Atanasov Nikolov <> Yuri Pankov
     <> Alberto Villa <> Brad Davis
     <> Matthew Seaman <> Bryan Drewery
     <> Eitan Adler <> Romain Tarti`ere
     <> Vsevolod Stakhov <> Alexandre
     Perrin <>

     See the issue tracker at

     Please direct questions and issues to the mailing list.

FreeBSD 11.0-PRERELEASE       September 14, 2013       FreeBSD 11.0-PRERELEASE


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

home | help