Pkg

Jul 20, 2023

Package manager

Package management tool


Introduction to pkg

FreeBSD is a robust operating system, but its power can truly be harnessed when you take advantage of its system of ports and packages. If you’re new to FreeBSD or a long-term user, it’s important to understand how to use the system package manager, pkg. It is a versatile tool, an essential part of the FreeBSD ports, that simplifies the process of installing, updating, and managing software packages on FreeBSD.

What is pkg?

Located in the ports-mgmt category, pkg is FreeBSD’s default package manager. It is used to augment FreeBSD’s binary package distribution system, install software from the FreeBSD ports tree, and perform tasks such as querying, installing, updating, and removing software packages.

Being a binary package management system, pkg downloads and installs precompiled software, which saves users the time and resources that would be consumed by building software from the source code. Its functionality could be likened to apt-get in Debian/Ubuntu based systems or yum in CentOS/RHEL based systems.

Installing and upgrading pkg

To get started with pkg, it must be installed on your FreeBSD system. In most modern FreeBSD installations, pkg is included by default. However, if it is not available, you can install it by executing the following command in a terminal

# pkg

The system will prompt you to install pkg. Press Y, then return to proceed. AT the end of the installation, you will be ready to start using pkg.

If pkg is installed already and you’d like to upgrade it to the latest version, use the following command

# pkg upgrade pkg

Using pkg to manage software packages

Installing a package is as simple as

# pkg install PACKAGENAME

This command retrieves the binary package from the FreeBSD servers and installs it. If the package is already installed, pkg will upgrade it to the latest version.

To remove a package, use

# pkg delete PACKAGENAME

Lists installed packages can be retrieved via

# pkg info

To update your system’s package repository catalogue

# pkg update

To upgrade all installed packages

# pkg upgrade

Each command offers numerous options and flags to provide flexibility and control. Check the manual pages man pkg for a deep dive into the full capabilities of pkg.

Benefits of using pkg

The pkg tool simplifies the process of managing software on FreeBSD. It automatically resolves and installs package dependencies, easing the software installation process. Essentially, this is what makes pkg an indispensable tool in a FreeBSD user’s toolbox.

With pkg, you don’t have to waste time compiling software from sources, that has already been compiled and is ready for use. This is especially beneficial on systems with limited resources.

The pkg system also offers an added advantage for IT security enthusiasts who can use it to install robust FreeBSD ports like [nmap]https//freebsdsoftware.org/security/nmap.html that help in network security auditing.

It also offers benefits beyond package installation. It can also verify installed packages, audit packages for known vulnerabilities, and provides tools to operate on packages in other ways like querying, validating, and extracting.

Conclusion

pkg is a fast, flexible, and practical command-line driven package management tool for FreeBSD. It provides an easy-to-use way for handling software and packages, ensuring that your FreeBSD system is a lot easier to manage and maintain.

Being proficient in pkg will help you maintain the software on your system with ease, leaving you with more time to work on your server or system. Whether you’re new to FreeBSD or a long-serving user, pkg is a tool that is most certainly worth getting acquainted with.


Checkout these related ports:
  • Wanted-ports - Just depend on a configurable, arbitrary set of other ports
  • Synth - Custom package repository builder for FreeBSD and DragonFly
  • Submodules2tuple - GH_TUPLE generator for GitHub projects with submodules
  • Sccache-overlay - Ports overlay for sccache
  • Reprise - Port testing system
  • Rc-subr-jail - Shell library to help writing RC scripts with jail support
  • Py-skog - Generate visual dependency trees for FreeBSD ports
  • Py-pytoport - Generate FreeBSD ports from Python modules on PyPI
  • Py-freebsd-ports - Parse FreeBSD Ports INDEX, provide search API
  • Psearch - Utility for searching the FreeBSD Ports Collection
  • Poudriere - Port build and test system
  • Poudriere-devel - Port build and test system
  • Portupgrade - FreeBSD ports/packages administration and management tool suite
  • Portupgrade-devel - FreeBSD ports/packages management tool (devel version)
  • Portupdate-scan - Display pertinent parts of {PORTSDIR}/UPDATING