FreeBSD package management

(This information is now available in our wiki in table format.)

The following is a short of cheat sheet I’ve put together for FreeBSD management.  All this information is available in the FreeBSD manual, but I prefer the “to the point” format of a cheat sheet.

Note that along with the individual package management commands, the sysinstall(8) utility can be used to install, delete, and list available and installed packages on a running system.

Packages page in the Freebsd manual:

The sysinstall utility can be invoked on a running system to install, delete, and list available and installed packages.

Finding a packages:



In FreeBSD (both make use of the ports system to find packages, dont’t feel you have to install the port):

whereis command

# whereis lsof
lsof: /usr/ports/sysutils/lsof

make command

# cd /usr/ports
# make search name=lsof
Port:   lsof-4.56.4
Path:   /usr/ports/sysutils/lsof
Info:   Lists information about open files (similar to fstat(1))
Index:  sysutils

Port gives you the package/port name.
Path tell’s you where to find the package/port.

The  example, the lsof package can be found in:

Package management

Adding a packages from a local file

# pkg_add <package-file>

Adding a package from a remote server

# pkg_add -r <package-file>

Two environment variables affect where pkg_add will pull it’s packages from
when the -r option is used.

$PACKAGEROOT specifies an alternate server for pkg_add to fetch from.
Example: “”

$PACKAGESITE specifies an alternate server with a full path for pkg_add to fetch from.
Thus it should be a complete URL to the remote package file(s).

Listing packages

pkg_info <options> <file|package name>
When run with no options, lists installed packages

– pkg_version:  Compares version of installed package to the version in the ports directory.

Removing  packages

pkg_delete <package-name>
Example:  pkg_delete xchat-1.7.1

pkg_add: Specifying a mirror server

Pretty simple, just set the PACKAGEROOT environment variable.  For example:


There are other variables you can set, but they require more specific paths.  What I like about PACKAGEROOT is it lets you specify your mirror and let pkg_add figure out the rest.

A list of FreeBSD mirrors can be found at

Update: On OpenBSD a similar variable is used: PKG_PATH.