PKG(7)
πΈ PKG(7) πΈ
okay bestie so this is the manual page for pkg β it lives in the Miscellaneous Information Manual section and honestly? it's the glow-up era of package management. sit down, grab a strawberry drink π, and let's get into it.
β¨ NAME β¨
pkg β a utility for manipulating packages π
π¦ SYNOPSIS π¦
pkg [-d] command ...
pkg [-d] add [-fy] [-r reponame] pkg.pkg
pkg -N
pkg [-46d] bootstrap [-fy] [-r reponame]
π DESCRIPTION π
pkg is the package management tool. periodt. it's what you use to manage the local packages you installed from ports(7), and also to install/upgrade packages from remote repositories. it's giving main character energy, fr fr.
so here's the thing β to avoid backwards incompatibility issues (ugh, the drama), the actual pkg(8) tool is not installed in the base system. nope. the first time you invoke it, pkg will bootstrap the real pkg(8) from a remote repository. iconic behaviour honestly.
pkg command ... if pkg(8) isn't installed yet, it gets fetched, has its signature verified, gets installed, and then your original command gets forwarded to it. if it's already installed? the command you asked for just gets forwarded straight to the real pkg(8). no cap. π«Ά
pkg add [-fy] [-r reponame] pkg.pkg install pkg(8) from a local package instead of fetching from remote. if signature checking is enabled, then the correct signature file must exist and the signature must be valid before the package will be installed β no shortcut, bestie. if the -f flag is specified, then pkg(8) will be installed regardless of whether it's already installed. and if the -y flag is specified, no confirmation will be asked when bootstrapping pkg(8).
if a reponame has been specified, then the signature configuration for that repository will be used. π
pkg -N 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. simple as that. β
pkg [-46] bootstrap [-fy] [-r reponame] attempt to bootstrap and do not forward anything to pkg(8) after it's installed. with -4 and -6, pkg will force IPv4 or IPv6 respectively to fetch pkg(8) and its signatures as needed. if the -f flag is specified, then pkg(8) will be fetched and installed regardless of whether it's already installed. if the -y flag is specified, no confirmation will be asked when bootstrapping pkg(8).
if a reponame has been specified, then the configuration for that repository will be used.
π OPTIONS π
the following options are supported by pkg:
-d,--debugβ show debug information. may be specified more than once to increase the level of detail π₯. when specified twice,fetch(3)debug output is enabled. iykyk.
π CONFIGURATION π
configuration varies in whether it's in a repository configuration file or the global configuration file. the default repository configuration for FreeBSD is stored in /etc/pkg/FreeBSD.conf, and additional repository configuration files will be searched for in REPOS_DIR, or /usr/local/etc/pkg/repos if it is unset. β¨
for bootstrapping, pkg will process all repositories that it finds and use the last enabled repository by default.
repository configuration is stored in the following format:
FreeBSD: {
url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
mirror_type: "srv",
signature_type: "none",
fingerprints: "/usr/share/keys/pkg",
enabled: yes
}
urlβ refer toPACKAGESITEin βENVIRONMENTβ πmirror_typeβ refer toMIRROR_TYPEin βENVIRONMENTβsignature_typeβ refer toSIGNATURE_TYPEin βENVIRONMENTβfingerprintsβ refer toFINGERPRINTSin βENVIRONMENTβenabledβ defines whether this repository should be used or not. valid values areyes,true,1,no,false,0.
global configuration can be stored in /usr/local/etc/pkg.conf in the following format:
PACKAGESITE: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
MIRROR_TYPE: "srv",
SIGNATURE_TYPE: "none",
FINGERPRINTS: "/usr/share/keys/pkg",
ASSUME_ALWAYS_YES: "yes"
REPOS_DIR: ["/etc/pkg", "/usr/local/etc/pkg/repos"]
reference βENVIRONMENTβ for each variable. π
π§ ENVIRONMENT π§
the following environment variables can be set to override the settings from the pkg.conf file used:
MIRROR_TYPEβ this defines which mirror type should be used. valid values areSRV,HTTP,NONE.ABIβ this defines the ABI for the package to be installed. the default ABI is determined from/bin/sh.ASSUME_ALWAYS_YESβ if set, no confirmation will be asked when bootstrappingpkg(8).SIGNATURE_TYPEβ if set toFINGERPRINTSthen a signature will be required and validated against known certificate fingerprints when bootstrappingpkg(8).FINGERPRINTSβ ifSIGNATURE_TYPEis set toFINGERPRINTSthis value should be set to the directory path where known fingerprints are located.PACKAGESITEβ the URL thatpkg(8)and other packages will be fetched from.REPOS_DIRβ comma-separated list of directories that should be searched for repository configuration files.
π¦ 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). π₯
/usr/local/etc/pkg.conf/etc/pkg/FreeBSD.conf/usr/local/etc/pkg/repos/*.conf
β EXAMPLES β
some examples are listed here. the full list of available commands is 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 pkg-autoremove(8) from removing it:
% pkg set -A 0 perl
change a package from non-automatic to automatic, which will make pkg-autoremove(8) allow it to 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
fetch a package for a different FreeBSD version, along with all its dependencies:
# pkg -o ABI=FreeBSD:15:amd64 -o IGNORE_OSVERSION=yes fetch -o
destdir -d perl
π also note the synopsis up top mentionspkg [-d] addandpkg [-46d] bootstrapβ the-ddebug flag rides along with those too, bestie.
π SEE ALSO π
πΈ HISTORY πΈ
the pkg 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), pkg_info(1) and pkg_create(1). glow-up of the century, honestly. β¨
and that's the whole page, bestie π«Ά this edition is from Debian, dated April 29, 2025 β mwah, go install something cute π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2013 Bryan Drewery <bdrewery@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms