At the present time, FreeBSD is transitioning toward a new
method of package management. Users of the latest releases
may wish to investigate the benefits of using
PKGng to manage third
party software on FreeBSD. For those not yet migrated to the
pkgng tool, the tools discussed
here may be used for managing the package database. For
simplicity, the sysinstall
utility is
also available post-install for package management.
All package installation files are stored in the
package database directory,
/var/db/pkg
.
Use pkg_add(1) to install a FreeBSD binary package from a local file or from a server on the network.
#
ftp -a ftp2.FreeBSD.org
Connected to ftp2.FreeBSD.org.
220 ftp2.FreeBSD.org FTP server (Version 6.00LS) ready.
331 Guest login ok, send your email address as password.
230-
230- This machine is in Vienna, VA, USA, hosted by Verio.
230- Questions? E-mail freebsd@vienna.verio.net.
230-
230-
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
cd /pub/FreeBSD/ports/packages/sysutils/
250 CWD command successful.
ftp>
get lsof-4.56.4.tgz
local: lsof-4.56.4.tgz remote: lsof-4.56.4.tgz
200 PORT command successful.
150 Opening BINARY mode data connection for 'lsof-4.56.4.tgz' (92375 bytes).
100% |**************************************************| 92375 00:00 ETA
226 Transfer complete.
92375 bytes received in 5.60 seconds (16.11 KB/s)
ftp>
exit
#
pkg_add lsof-4.56.4.tgz
If you do not have a source of local packages, such as a
FreeBSD CD-ROM set, include -r
with
pkg_add(1). This automatically determines the correct
object format and release, and then fetches and installs the
package from an FTP site without any further user
intervention.
#
pkg_add -r lsof
To specify an alternative FreeBSD FTP mirror, specify the
mirror in the PACKAGESITE
environment variable.
pkg_add(1) uses fetch(3) to download files, which
uses various environment variables, including
FTP_PASSIVE_MODE
, FTP_PROXY
, and
FTP_PASSWORD
. You may need to set one or more
of these if you are behind a firewall, or need to use an
FTP/HTTP proxy. See fetch(3) for the complete list of variables.
Note that in the example above lsof
is used
instead of lsof-4.56.4
. When the remote
fetching feature is used, the version number of the package
must be removed.
pkg_add(1) will automatically download the latest
version of the application if you are using FreeBSD-CURRENT or
FreeBSD-STABLE. If you run a -RELEASE version, it instead
installs the version of the package that was built with that
release. It is possible to change this behavior by
overriding PACKAGESITE
. For example, on a
FreeBSD 8.1-RELEASE system, by default pkg_add(1)
will try to fetch packages from
ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.1-release/Latest/
.
To force pkg_add(1) to download FreeBSD 8-STABLE
packages, set PACKAGESITE
to
ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8-stable/Latest/
.
Package files are distributed in .tgz
and .tbz
formats. Packages are
available from ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/packages/,
or the /packages
directory of the FreeBSD
DVD distribution. The layout of the packages directory is similar to
that of the /usr/ports
tree. Each
category has its own directory, and every package can be found
within the All
directory.
pkg_info(1) can be used to list and describe installed packages:
#
pkg_info
colordiff-1.0.13 A tool to colorize diff output
docbook-1.2 Meta-port for the different versions of the DocBook DTD
...pkg_version(1) summarizes the versions of all installed packages and compares the package version to the current version found in the ports tree.
#
pkg_version
colordiff =
docbook =
...The symbols in the second column indicate the relative age of the installed version and the version available in the local ports tree.
Symbol | Meaning |
---|---|
= | The version of the installed package matches the one in the local ports tree. |
< | The version of the installed package is older than the one in the local ports tree. |
> | The version of the installed package is newer than the one in the local ports tree, meaning that the local ports tree is probably out of date. |
? | The installed package cannot be found in the ports index. This can happen when an installed port is removed from the Ports Collection or is renamed. |
* | There are multiple versions of the package. |
! | The installed package exists in the index but for
some reason, pkg_version was unable
to compare the version number of the installed package
with the corresponding entry in the index. |
To remove a previously installed software package, use pkg_delete(1):
#
pkg_delete xchat-1.7.1
Note that pkg_delete(1) requires the full package
name and number; the above command would not work if
xchat
was given instead of
xchat-1.7.1
. Use
pkg_version(1) to find the version of the
installed package, or use a wildcard:
#
pkg_delete xchat\*
in this case, all packages whose names start with
xchat
will be deleted.
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.