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

Usage Description
pkg history package_names... List version history of packages
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 list -installed-names List installed package names
pkg list -dependencies package_names... List package dependencies
pkg list -dependents package_names... List dependent 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
-keepgoing Continue when errors occur
-legacy Include legacy packages
-nodelete Don't delete downloaded packages after installation
-noverify Don't verify downloaded packages
-outputformat string Specify list/search output format string
-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
Macro Description
$(Description) Package description
$(Name) Package name
$(Title) Package title
$(Version) Package version

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 libcxx
libcxx_arm - ARM libcxx Library Package (1.1)

The install command can be used to install a package:

$ pkg install libcxx_arm

The list command can be used to list installed packages:

$ pkg list -installed
libcxx_arm - ARM libcxx Library Package (1.1)

The history command can be used to show package history:

$ pkg history libcxx_arm
libcxx_arm - libcxx Library Package [ARM]

  1.1 (Installed)
    - Fixed name of Type Interpretation File.

  1.0
    - Initial release.

Specific versions of a package can be installed:

$ pkg install libcxx_arm:1.0

The upgrade command can be used to upgrade to the latest version of a package:

$ pkg upgrade libcxx_arm

The remove command can be used to uninstall a package:

$ pkg remove libcxx_arm