Using FreeBSD Ports & Packages


06 Feb 2015

Using FreeBSD Ports & Packages

Preston Garrison 0 Comments

The following is a run down of the basic ports and packages commands.   On the most part its probably best to use the pkg utility since it doesn’t compile packages, and consequently would be much quicker, however there are times when a port may exist that does not exist as a package.  Ports also has a very high likelihood that during install of other packages, the installation may fail.  Ports will try to install and compile all other ports required to install the port you selected.  If you do have it break during installation of other packages, you can usually use the pkg command to install that package directly, and then attempt to install the port again.






 pkg update


Search for a package

pkg search (partial_package_name)


Install a package

pkg install (package_name)


 To force a package and all dependent packages to reinstall

pkg install -Rf (package_name)

 Its a good idea to do this if you change versions of a package, or upgrade one.


To update all packages installed


pkg upgrade





The very first time you install ports you should following commands:

portsnap fetch extract

After the first use you can update ports with:

portsnap fetch update

You can then install ports by doing the following:

cd /usr/ports/*/portname*
make install clean

sometimes more then on port may match, so you have to cd to the category dir and try and find it manually


Installing older ports:

Sometimes it is necessary to install older ports.  A good example of this is python recently made ssl certificates required to be valid in version 2.7.9.   Downgrading to 2.7.8 is a good idea to keep software that relies on ssl certs from breaking.

The simplest thing is to just edit the Makefile of the port, and replace the following line:


this installs version 2.7.8 of the port



For more information click here