pkg
Manage software packages
SYNOPSIS
pkg [global_options] command [command_options] [arguments]
PARAMETERS
-y
Assume 'yes' to all queries without prompting. Useful for non-interactive scripts.
-f
Force the requested operation, overriding checks or existing conditions where appropriate.
-q
Operate quietly, suppressing most informational output messages.
-v
Operate verbosely, showing more detailed output about the ongoing operation.
-r <repo>
Specify the repository from which to fetch packages. Overrides default repository configuration for the command.
-C
Do not use the local package cache; forces a re-download of metadata from remote repositories.
-o <option=value>
Set a specific configuration option for the command. Can be used multiple times.
-R <rootdir>
Use <rootdir> as the root directory for all operations (similar to a chroot environment).
-s
Perform operations in a 'sandbox' or simulated mode (dry run) without making actual changes.
-U
Do not update the repository metadata from the remote source before executing the command.
DESCRIPTION
pkg is the official binary package management utility for FreeBSD and other BSD-based operating systems. It provides a robust, dependency-aware framework for installing, upgrading, and removing pre-compiled software packages. It handles complex dependency chains, ensures consistent system state, and allows for safe upgrades and easy rollbacks. pkg interacts with remote repositories to fetch and manage packages, offering features like package auditing for known vulnerabilities, automatic removal of orphaned dependencies, and query capabilities for installed software.
Important Note: While the prompt asks for a 'Linux command', pkg is primarily known and used as the package manager for FreeBSD. Linux distributions use different package managers like apt (Debian/Ubuntu), yum/dnf (Red Hat/Fedora), or pacman (Arch Linux). A standalone pkg command is not natively available or commonly used on most Linux systems.
CAVEATS
pkg is the primary package management tool for FreeBSD and other BSD derivatives, not for standard Linux distributions. While some Linux environments might contain a tool named 'pkg' (e.g., specific development tools or custom setups), it is not part of the core Linux utility set. Users on Linux systems should typically use their distribution's native package manager (e.g., apt, dnf, pacman, zypper) to manage software packages.
COMMON COMMANDS
pkg operates through a series of subcommands that define the action to be performed. Here are some of the most frequently used:
install <pkg_name>: Installs one or more specified packages.
remove <pkg_name>: Removes one or more specified packages.
update: Fetches the latest package catalog (metadata) from configured repositories.
upgrade: Upgrades all installed packages to their latest available versions based on the updated catalog.
search <term>: Searches for packages matching a specified term in the repository catalogs.
info <pkg_name>: Displays detailed information about an installed or available package.
autoremove: Removes packages that were installed as dependencies and are no longer required by any other installed software.
clean: Clears the local package cache of downloaded package files to free up disk space.
CONFIGURATION
pkg's behavior and repository settings are controlled by configuration files. The primary configuration file is typically /usr/local/etc/pkg.conf. Repository definitions are managed in files within the /usr/local/etc/pkg/repos/ directory. These files define repository URLs, package signing keys, and other system-wide preferences, allowing for flexible management of package sources.
HISTORY
The pkg utility for FreeBSD was developed to modernize and replace the older pkg_install tools. It was designed to provide a more robust, transactional, and user-friendly experience for managing binary packages. It became the official package manager starting with FreeBSD 10.0-RELEASE. Its development aimed to address limitations of previous systems, offering improved dependency resolution, integrity checking, and repository management.