The pkg program can be used to download, install, remove and search for packages from the command line.

Usage Description
pkg install package_names... Download and install packages
pkg install -manual package_files... Manually install package files
pkg list List all available packagess
pkg list -installed List installed packages
pkg remove package_names... Remove packages
pkg remove -all Remove all packages
pkg search keywords... Search for packages
pkg update Update list of available packages
pkg upgrade Upgrade all installed packages
pkg upgrade package_names... Upgrade selected packages
Option Description
-D macro=value Set a global macro
-legacy Include legacy packages
-nodelete Don't delete downloaded packages after installation
-noverify Don't verify downloaded packages
-packagesdir directory Set the packages directory to be directory
-packagesurl url Set the URL of the packages website to be url
-quiet Do not output any progress messages
-rootuserdir directory Set the root user data directory to directory
-verbose Produce verbose output
-yes Answer yes to all questions without prompting

Before you can download, install or search for packages you must first update the local list of available packages:

$ pkg update

The search command can be used to search for a specific package:

$ pkg search STL
STLport (1.0) - STLport Library Package

The install command can be used to install a package:

$ pkg install STLport

The list command can be used to list installed packages:

$ pkg list -installed
STLport (1.0) - STLport Library Package

The remove command can be used to uninstall a package:

$ pkg remove STLport