Pkg

From GhostBSD Wiki
Jump to: navigation, search
Application Management
pkg Software Station Update Station Ports Applications
Back to the Icon Disti GhostBSD.pngWiki

Introduction[edit]

pkg is the FreeBSD package management tools, offering many features that make dealing with binary packages faster and easier. See pkg(8)

Package Benefits

  • A compressed package tarball is typically smaller than the compressed tarball containing the source code for the application.
  • Packages do not require compilation time. For large applications, such as Mozilla, KDE, or GNOME, this can be important on a slow system.
  • Packages do not require any understanding of the process involved in compiling software on FreeBSD.

Overview About PKG Commands[edit]

Command Explanation
help command Display usage information of the specified command.
add Install a package from either a local source or a remote one.
When installing from remote source you need to specify the proto-
col to use when fetching the package.

Currently supported protocols are FTP, HTTP and HTTPS.
annotate: Add, modify or delete tag-value style annotations on packages.

alias display configured aliases
annotate Add, modify or delete arbitrary annotations from packages
audit Audit installed packages against known vulnerabilities.
autoremove Delete packages which were automatically installed as dependen-
cies and are not required any more.
backup Dump the local package database to a file specified on the command-line.
bootstrap This is for compatibility with the pkg(7) bootstrapper. If pkg is already installed, nothing is done. If invoked with the -f flag an attempt will be made to reinstall pkg from remote repository.
check Sanity checks installed packages.
clean Clean the local cache of fetched remote packages.
config retrieve the value of a given configuration option
convert Convert to and from the old pkg_add(1) format.
create Create a package, a utility for creating software package distributions.
delete Delete a package from the database and the system.
fetch Fetch packages from a remote repository.
info Display information about installed packages.
install Install a package from a remote package repository. If a package is found in more than one remote repository, then installation happens from the first one. Downloading a package is tried from each package repository in turn, until the package is successfully fetched.
lock Prevent modification or deletion of a package, lock or unlock packages.
plugins List the available plugins.
query Query information about installed packages.
register Register a package in the database.
repo Create a local package repository for remote usage.
rquery Query information for remote repositories.
search Search for the given pattern in the remote package repositories.
set Modify information in the installed database.
shell Open a SQLite shell to the local or remote database. Extreme

care should be taken when using this command.

shlib Displays which packages link to a specific shared library.
stats Display package database statistics.
unlock Unlocks packages, allowing them to be modified or deleted.
update Update the available remote repositories as listed
in /usr/local/etc/pkg/repos/GhostBSD.conf
updating Display UPDATING entries of installed packages.
upgrade Upgrade a package to a newer version.
version Summarize installed versions of packages.
which Query the database for package(s) that installed a specific file.
See also
pkg_printf family of functions produces output of package data according to a format
pkg_repos() Takes the address of a pointer to the repository
package repository format and operation of package repositories used by pkg(8)
pkg.conf system-wide configuration file for pkg, default location of this file is /usr/local/etc/pkg.conf

Function and Examples[edit]

A package can be manipulated with the pkg(8) commands, such as pkg install.

pkg only works with binary packages. By default, pkg uses the binary packages from the GhostBSD package mirrors.

Each pkg command argument is documented in a command-specific manual page. To read the manual page for pkg install, for example, run either of these commands:

# pkg help install

or

# man pkg-install

Installing Packages[edit]

To install a binary package use the following command, where packagename is the name of the package to install:

# pkg install packagename

This command uses repository data to determine which version of the software to install and if it has any uninstalled dependencies.

Removing Packages[edit]

Packages that are no longer needed can be removed with pkg delete. For example:


# pkg delete packagename

Upgrading Installed Packages[edit]

Update the local package repository index

# pkg update

Installed packages can be upgraded to their latest versions by running:

# pkg upgrade

This command will compare the installed versions with those available in the repository catalogue and upgrade them from the repository.

If a kernel has to be upgraded, you have to do a forced upgrade. It is needed that all packages have to be reinstalled, so that all the package are compiled with the right kernel.

# pkg update -f

# pkg upgrade -fy

Not Updating A Package[edit]

If you have got an application via the ports system and don't like to change it during pkg upgrade process, do

#pkg lock packagename

To Get Info About An Installed Package[edit]

If you like to know if a package is installed and which version, you have to write:

pkg info packagename

Auditing Installed Packages[edit]

Software vulnerabilities are regularly discovered in third-party applications. To address this, pkg includes a built-in auditing mechanism. To determine if there are any known vulnerabilities for the software installed on the system, run:

# pkg audit -F

-F, --fetch Fetch the database before checking.

Automatically Removing Unused Packages[edit]

Removing a package may leave behind dependencies which are no longer required. Unneeded packages that were installed as dependencies (leaf packages) can be automatically detected and removed using:

# pkg autoremove

Repositories[edit]

The pkg mirrors are located in:

To change the mirror go to the file /etc/pkg/GhostBSD.conf and change the URL.
There in it is described as:

For upgrading your system chose the nearest mirror to your location.

For more Information[edit]

Sources: