The pkgng is the package management system in FreeBSD. It is used to install applications, and specific modules, libraries, etc. Nowadays you can select in between more than 25.000 thousand. Yes, twenty five thousand. The syntax to use is very intuitive and simple.
As you may be already aware software comes in two forms. Source and binaries. Often times you have been consuming software in the latter form. This is where tools like pkgng come in. FreeBSD has made the process of installing software in both ways an easy task. Binaries are just compiled versions from source code. Therefore someone has set the options at compile time for you. Most of the times this options are the most common ones and the resulting binary is ready to be used in production. However you may be a developer, a maniac, a curious person, or someone at a company setting a sane environment for your specific needs. Then FreeBSD provides you the ports collection, a set of utilities and framework for you to compile the software easily and safely.
If you find the articles in Adminbyaccident.com useful to you, please consider making a donation.
That said, let’s tackle the basic form of software installation by using the pkgng utility to install binaries. Just type “pkg” to bootstrap pkgng. After that you will be able to install, delete, and set some conditions in the binaries already packaged for FreeBSD. This is very similar to use to the apt-get found in the Debian-based distributions, the yum from RHEL or the zypper tool from the SUSE Linux.
This is the list of commands you will be able to use with the pkg tool. You can also find this list if you type: “man pkg”. To quit the interface just type the letter: “q”.
The following commands are supported by pkg:
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
protocol to use when fetching the package.
Currently supported protocols are FTP, HTTP and HTTPS.
Add, modify or delete tag-value style annotations on packages.
audit Audits installed packages against known vulnerabilities.
Delete packages which were automatically installed as
dependencies and are not required any more.
backup Dump the local package database to a file specified on the
check Sanity checks installed packages.
clean Cleans the local cache of fetched remote packages.
Convert to and from the old pkg_add(1) format.
create Create a package
delete Delete a package from the database and the system.
fetch Fetches packages from a remote repository.
info Display information about installed packages.
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
lock Prevent modification or deletion of a package.
List the available plugins.
query Query information about installed packages.
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 Fires up 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
Displays UPDATING entries of installed packages.
Upgrade a package to a newer version.
Summarize installed versions of packages.
which Query the database for package(s) that installed a specific file.
You may wonder which is the best way to install software in FreeBSD. Ports offers flexibility for those who know what they want and have some specific and particular needs. For the rest, as it happens in most of the GNU/Linux distributions, packages are the way to go. They are sanely compiled and you will safe a significant amount of time. If you happen to manage software for a small team or you work at a company and you are in charge of the software selection don’t forget to look for the poudriere utility. You can create your own compiled binaries repository and your users can pull those from you and not from the main project repo.
Use this link to get 100 $ credit at DOcean and support Adminbyaccident.com hosting costs.