Admin... by accident!

You may have chosen to be an admin. I didn't!

  • Home
  • FreeBSD
  • GNU/Linux
  • Security
  • Network
  • Virtualization
  • Politics
  • Github
  • Donate
  • Me

How to install software in FreeBSD with pkgng

April 25, 2017 by Albert Valbuena

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.

Use this link to get $200 credit at DigitalOcean and support Adminbyaccident.com costs.

Get $100 credit for free at Vultr using this link and support Adminbyaccident.com costs.

Mind Vultr supports FreeBSD on their VPS offer.

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:

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
protocol 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.

audit   Audits installed packages against known vulnerabilities.

autoremove
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
command-line.

check   Sanity checks installed packages.

clean   Cleans the local cache of fetched remote packages.

convert
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
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.

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   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
pkg.conf(5).

updating
Displays 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.

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.

If you find the articles in Adminbyaccident.com useful to you, please consider making a donation.

Use this link to get $200 credit at DigitalOcean and support Adminbyaccident.com costs.

Get $100 credit for free at Vultr using this link and support Adminbyaccident.com costs.

Mind Vultr supports FreeBSD on their VPS offer.

 

Filed Under: How To's

Recent Posts

  • How to install Redis for WordPress on FreeBSD
  • How to compile cloudflared in FreeBSD 13/14
  • How to configure FreeBSD to use a webcam (version 12 and 13)
  • Symbolic and Hard Links in UNIX and Linux
  • How to import iocage jails to Bastille on FreeBSD 13
  • How to load and unload kernel modules in Linux
  • How to use find in GNU/Linux and FreeBSD
  • How to install Mate on FreeBSD 12/13
  • How to install Nessus 10 on FreeBSD 12
  • How to enable TLS traffic from the origin server on Cloudflare Argo Tunnel
  • How to use Cloudflare’s Argo Tunnel service to publish a website on FreeBSD 12/13
  • How to setup MariaDB master-slave replication on FreeBSD
  • How to upload a FreeBSD custom image on DigitalOcean
  • How to install Drupal 9 on FreeBSD 13.0
  • How to manage site visitors based on IP Geolocation
  • How to enable Geolocation in AWStats on FreeBSD 13.0
  • How to install AWStats on FreeBSD 13.0
  • How to configure Modsecurity 3 for WordPress on FreeBSD
  • How to configure Apache HTTP with a TLS reverse proxy backend on FreeBSD
  • How to detect a WAF – Web Application Firewall

Archives

  • November 2024
  • October 2024
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • April 2022
  • March 2022
  • October 2021
  • September 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • September 2018
  • June 2018
  • May 2018
  • April 2018
  • February 2018
  • January 2018
  • November 2017
  • April 2017

RSS Admin… by accident!

  • How to install Redis for WordPress on FreeBSD
  • How to compile cloudflared in FreeBSD 13/14
  • How to configure FreeBSD to use a webcam (version 12 and 13)
  • Symbolic and Hard Links in UNIX and Linux
  • How to import iocage jails to Bastille on FreeBSD 13
  • How to load and unload kernel modules in Linux
  • How to use find in GNU/Linux and FreeBSD
  • How to install Mate on FreeBSD 12/13
  • How to install Nessus 10 on FreeBSD 12
  • How to enable TLS traffic from the origin server on Cloudflare Argo Tunnel

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in