FreeBSD Miscellaneous Information Manual
NAME pkg — a utility for manipulating packages
is the package management tool. It is used to manage local packages installed from ports(7)
and install/upgrade packages from remote repositories.
To avoid backwards incompatibility issues, the actual pkg(8) tool is not installed in the base system. The first time invoked, pkg will bootstrap the real pkg(8) from a remote repository.
If pkg(8) is not installed yet, it will be fetched, have its signature verified, installed, and then have the original command forwarded to it. If already installed, the command requested will be forwarded to the real pkg(8).
add [-f] <pkg.txz>
Install pkg(8) from a local package instead of fetching from remote. If a pkg.txz.sig file exists and signature checking is enabled, then the signature will be verified before installing the package. If the -f flag is specified, then pkg(8) will be installed regardless if it is already installed.
Do not bootstrap, just determine if pkg(8) is actually installed or not. Returns 0 and the number of packages installed if it is, otherwise 1.
Attempt to bootstrap and do not forward anything to pkg(8) after it is installed. If the -f flag is specified, then pkg(8) will be fetched and installed regardless if it is already installed.
Configuration varies in whether it is in a repository configuration file or the global configuration file.
Repository configuration can be stored in /etc/pkg/FreeBSD.conf in the following format:
Refer to PACKAGESITE in ENVIRONMENT
Refer to MIRROR_TYPE in ENVIRONMENT
Refer to SIGNATURE_TYPE in ENVIRONMENT
Refer to FINGERPRINTS in ENVIRONMENT
Defines whether this repository should be used or not. Valid values are yes, true, 1, no, false, 0.
Global configuration can be stored in /usr/local/etc/pkg.conf in the following format:
REPOS_DIR: ["/etc/pkg", "/usr/local/etc/pkg/repos"]
Reference ENVIRONMENT for each variable.
The following environment variables can be set to override the settings from the pkg.conf
This defines which mirror type should be used. Valid values are SRV, HTTP, NONE.
This defines the ABI for the package to be installed. Default ABI is determined from /bin/sh.
If set, no confirmation will be asked when bootstrapping pkg(8).
If set to FINGERPRINTS then a signature will be required and validated against known certificate fingerprints when bootstrapping pkg(8).
If SIGNATURE_TYPE is set to FINGERPRINTS this value should be set to the directory path where known fingerprints are located.
The URL that pkg(8) and other packages will be fetched from.
Comma-separated list of directories that should be searched for repository configuration files.
Configuration is read from the files in the listed order. This path can be changed by setting REPOS_DIR
. The last enabled repository is the one used for bootstrapping pkg(8)
Some examples are listed here. The full list of available commands are available in pkg(8)
once it is bootstrapped.
Search for a package:
$ pkg search perl
Install a package:
% pkg install perl
List installed packages:
$ pkg info
Upgrade from remote repository:
% pkg upgrade
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
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
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
Create package file from an installed package:
% pkg create -o /usr/ports/packages/All perl
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
command first appeared in FreeBSD 9.1
. It became the default package tool in FreeBSD 10.0
, replacing the pkg_install suite of tools pkg_add(1)