FreeBSD Challenge: Day 03 of 30

Well, due to some unforeseen “new home-owner” emergency (good bye ol’ fridge, it was grand!), tonight may be a short update.   Today I wanted to explore package management on FreeBSD, and install a few common items to get accustomed to the process.  Have no fear, FreeBSD is here!


  • Installing using the default package manager
  • Installing software using the Ports system
  • What alternative methods exist?
  • Can I find my general use programs and install them with little to no fuss?

Installing software on FreeBSD out of the box

With a clean system up and running, and root access, installing software packages isn’t overly complicated.  The hardest part is getting accustomed to the right commands for installation, updating, and upgrades of the system.  The suggested default method of program installing is through the pkg* system.  Here is a an overview of common pkg tasks:

  • pkg_add: Extracts and installs packages that have been previously created with pkg_create.
  • pkg_create: Creates packages that feed into extraction/information utilities.
  • pkg_delete: Removes packages that were previously installed with pkg_add.
  • pkg_info: Retrieves information about a given package.
  • pkg_fetch: Download binary packages from remote sites.

The most commonly used optoin of pkg_add used is -r for fetching from remote sites as a source of the package.  Let’s try to install a few packages with this method:

#pkg_add -r firefox

Installation was painless.  But, what if your package isn’t found?  In this example, I learn that there is not a precompiled package for Google’s Chrome browser.  Although I was not quite sure how to search using pkg_*, I soon discovered the power of pkgng.

Using pkgng

“pkgng” is the cool kid on the block, the fresh, the hip, the kind your mom doesn’t want you hanging around.  I found pkgng to be a little easier to use that ol’ pkg_* and the like.  Documentation will point you to t he proper process for getting underway.  Please note this step is not reversible. Once the package database has been converted to the pkgng format, the traditional pkg_* tools should not be used.

# cd /usr/ports/ports-mgmt/pkg
# make
# make install clean

This bit of code will install pkg from the Ports tree and subsequently convert the old package system into what pkgng likes best.  Package repositories for pkgng can be edited in the “/usr/local/etc/pkg.conf” file as root.  For all intensive purposes, I left this at its default for now.  Using pkgng seemed a little more “verbose” and written out in plain English.  I quite liked it.  Some common task are:

  • pkg info <pkg_name>: Retrieves detailed information for available packages.
  • pkg search <pkg_name>: Retrieve matching package names only.
  • pkg install <pkg_name>: Installs a new package from a remote repository (pkg add can be used for remote or local installations).
  • pkg autoremove <pkg_name>: Remove an installed package along with any unneeded dependencies.
  • pkg backup: Runs a backup of your local database
  • pkg delete: Deletes a package from your system as well as the database.
  • pkg query: Retrieve information about your installed local packages
  • pkg -v: Query the version of an installed pacakge


The information you get from ‘pkg info’ is nice and informative.  Upgrading package is as easy as running pkg upgrade  A step in the right direction!  Even though I wasn’t immediately sure how to run partial name or wild card searches, it was very nice.  I very much liked the range of options available to pkgng, as well as the format of the information.  For binary packages, I decided to stick to pkgng.

Using the Ports system

One of the best things about FreeBSD I have found so far is the Ports system.  If you are coming form Arch, you may feel at home, drawing comparison to the Arch Linux ABS system, and its PKGBUILD files.  From what I can, out of the box you seem to have to update your Ports database on command, but there are tools available at your disposal if you do not like this (see portmaster).

There are two ways I found you do this.  One being Portsnap, and the other using Subversion (source control).  I opted for Portmaster, given the way it seemed to work.  Personally, I am not a big fan of Subversion (over git).

First, update Ports:

# portsnap fetch
# portsnap extract

After the first run, you can run ‘portsnap fetch’ and ‘portsnap update‘ to update your Ports tree.  I was used to compiling packages from source, so the concepts next presented to me of ‘./configure, make, make isntall’ made perfect sense.  Search and installing ports isn’t that difficult as well:

Searching the Ports tree

I found you can search the Ports tree a few different ways:

  • whereis <port_name>
  • echo /usr/ports/*/*lsof*

You may also change to the /usr/ports directory, and search directly from there:

cd /usr/ports
make search name=lsof

All of this is made possible through the use of an index under the Ports system.  Using Ports was not all that bad.  I have a feeling bad habits would push me into use pkgng over Ports, but coming from Arch Linux, and falling in love with ABS and the AUR, i’m sure I can train myself to rock out to the Ports system anytime.


Installing software on FreeBSD is not overly hard.  If you are coming from more graphical flavor of Linux, you will most certainly want to read the FreeBSD Handbook.  What lies within, Mr. Indiana Jones, is a treasure trove of precious information!  While I fond the FreeBSD docs to be quite well laid out, I found myself missing the easy to use Arch Linux wiki.  Rather than a topic tree, you are left to use next, back, and home text links.  Yes, I am a pain.  All in all I was quite pleased with the experience.

Coming tomorrow?  Installing all my software!  Can it be done?  To be honest, I will focus just on  my main programs I like to use, and investigate an alternative if it exists.  Also if you not already, check out the FreeBSD 101 Start Page.




[ Back To Index ]


About professorkaos64

Posted on 20131209, in Distro Test Drive, Distros and tagged , . Bookmark the permalink. 3 Comments.

  1. By the way, if you use pkgng you will want to sure you have WITH_PKGNG=yes in /etc/make.conf

  1. Pingback: FreeBSD Challenge | The Linux Cauldron

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s