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

FreeBSD Manual Pages

  
 
  

home | help
PKG(7)		   FreeBSD Miscellaneous Information Manual		PKG(7)

NAME
     pkg -- a utility for manipulating packages

SYNOPSIS
     pkg command ...
     pkg add [-fy] [-r reponame] pkg.txz
     pkg -N
     pkg [-46] bootstrap [-fy] [-r reponame]

DESCRIPTION
     pkg is the	package	management tool.  It is	used to	manage local packages
     installed from ports(7) and install/upgrade packages from remote reposi-
     tories.

     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.

     pkg command ...
	     If	pkg(8) is not installed	yet, it	will be	fetched, have its sig-
	     nature 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).

     pkg add [-fy] [-r reponame] pkg.txz
	     Install pkg(8) from a local package instead of fetching from re-
	     mote.  If signature checking is enabled, then the correct signa-
	     ture file must exist and the signature valid before the package
	     will be installed.	 If the	-f flag	is specified, then pkg(8) will
	     be	installed regardless if	it is already installed.  If the -y
	     flag is specified,	no confirmation	will be	asked when bootstrap-
	     ping pkg(8).

	     If	a reponame has been specified, then the	signature configura-
	     tion 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.

     pkg [-46] bootstrap [-fy] [-r reponame]
	     Attempt to	bootstrap and do not forward anything to pkg(8)	after
	     it	is installed.  With -4 and -6, pkg will	force IPv4 or IPv6 re-
	     spectively	to fetch pkg(8)	and its	signatures as needed.  If the
	     -f	flag is	specified, then	pkg(8) will be fetched and installed
	     regardless	if it is already installed.  If	the -y flag is speci-
	     fied, no confirmation will	be asked when bootstrapping pkg(8).

	     If	a reponame has been specified, then the	configuration for that
	     repository	will be	used.

CONFIGURATION
     Configuration varies in whether it	is 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 to PACKAGESITE in ENVIRONMENT
     mirror_type     Refer to MIRROR_TYPE in ENVIRONMENT
     signature_type  Refer to SIGNATURE_TYPE in	ENVIRONMENT
     fingerprints    Refer to FINGERPRINTS in ENVIRONMENT
     enabled	     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 fol-
     lowing 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 are SRV,	HTTP, NONE.

     ABI		This defines the ABI for the package to	be installed.
			Default	ABI is determined from /bin/sh.

     ASSUME_ALWAYS_YES	If set,	no confirmation	will be	asked when bootstrap-
			ping pkg(8).

     SIGNATURE_TYPE	If set to FINGERPRINTS then a signature	will be	re-
			quired and validated against known certificate finger-
			prints when bootstrapping pkg(8).

     FINGERPRINTS	If SIGNATURE_TYPE is set to FINGERPRINTS this value
			should be set to the directory path where known	fin-
			gerprints are located.

     PACKAGESITE	The URL	that pkg(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 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
     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	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

SEE ALSO
     ports(7), pkg(8)

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).

FreeBSD	13.0			 June 30, 2022			  FreeBSD 13.0

NAME | SYNOPSIS | DESCRIPTION | CONFIGURATION | ENVIRONMENT | FILES | EXAMPLES | SEE ALSO | HISTORY

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=pkg&manpath=FreeBSD+13.2-RELEASE+and+Ports>

home | help