pkg is a FreeBSD package management tool for installing third-party binaries.
# To search for a package:
pkg search perl
# To install a package:
pkg install perl
# To install a package: NOTE: Installing must specify a unique origin or version
# otherwise it will try installing all matches.
pkg install perl-5.14
# To list installed packages:
pkg info
# To upgrade from remote repository:
pkg upgrade
# To change the origin for an installed package:
pkg set -o lang/perl5.12:lang/perl5.14
pkg install -Rf lang/perl5.14
# To list non-automatic packages (packages that will not be removed with 'autoremove'):
pkg query -e '%a = 0' %o
# To list automatic packages (packages that will be removed with 'autoremove', once nothing depends on it)
pkg query -e '%a = 1' %o
# To delete an installed package:
pkg delete perl
# To delete a specific installed package:
pkg delete perl-5.14
# To remove unneeded dependencies:
pkg autoremove
# To change a package from automatic to non-automatic, which will prevent
# autoremove from removing it:
pkg set -A 0 perl
# To 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
# To create package file from an installed package:
pkg create -o /usr/ports/packages/All perl
# To determine which package installed a file:
pkg which /usr/local/bin/perl
# To audit installed packages for security advisories:
pkg audit
# To check installed packages for checksum mismatches:
pkg check -s -a
# To check for missing dependencies:
pkg check -d -a