Mastering FreeBSD's two software installation paths: pkg for fast binary packages and ports for building from source. You will learn the pkg update, install, upgrade, search, info, and autoremove flow, then compare the tradeoffs with ports and poudriere for your own build farm.

In the previous episode 3, you installed FreeBSD with bsdinstall and chose your partitioning. Your system is clean and ready to be filled. Now it's time to learn how to fill it with software — because FreeBSD without software is like a house without furniture.
FreeBSD offers two installation paths: pkg for binary packages and ports for building from source. They share the same foundation, but their workflows are very different. This episode covers both thoroughly, plus poudriere for those of you who want to build ports at scale yourself.
pkg pulls packages from the official pkg.FreeBSD.org repository. The first step you always take is updating the catalog:
pkg updateThe output shows the repo version and the number of available packages. Run this command periodically so pkg install and pkg upgrade always use current data.
Search for packages with pkg search, and install with pkg install:
pkg search nginx
pkg install nginxInfo
pkg resolves dependencies automatically. If nginx needs other libraries, they're all downloaded and installed at once — unlike a manual source-based approach where you have to handle them yourself.
To check what's installed and inspect package details:
pkg info
pkg info nginx
pkg info -l nginxpkg info -l lists the files owned by a package — useful for tracing which config file came from which package.
Updating the entire system and cleaning unused dependencies:
pkg upgrade
pkg autoremovepkg autoremove removes orphan packages — old dependencies no longer needed by any other package. Run it regularly so your system doesn't accumulate junk.
pkg supports custom repositories, including local repos built by poudriere. Repository configuration lives in /etc/pkg/*.conf and can be viewed with:
pkg reposOn modern releases, the ports tree is installed from git. In /usr/ports, you'll find thousands of port directories:
git clone --depth 1 https://git.FreeBSD.org/ports.git /usr/portsOn older releases, the portsnap command was once the standard, but git is now the recommended method because it supports updates and branches better.
Enter the port directory and run the build:
cd /usr/ports/www/nginx
make install cleanmake install clean will download the source, apply patches, compile according to your option choices, and install the result. This process takes much longer than pkg install, but gives you full control.
Before building, you can configure the port options:
make config
make config-recursivemake config-recursive opens the options menu for a port and all its dependencies. The option choices are saved in /var/db/ports, so subsequent builds stay consistent.
| Criterion | pkg | Ports |
|---|---|---|
| Speed | Instant | Slow (compile) |
| Optimization | Generic | Hardware-specific |
| Option control | Limited | Full |
| Toolchain required | No | Yes (compiler, make) |
| Best for | General users | Appliances, custom tuning |
Warning
Don't mix too many pkg packages and manual ports builds without thinking. If you install the binary nginx and then build nginx from ports, pkg will lose track. For consistency, pick one dominant path — or use poudriere so everything is built from source but still managed by pkg.
poudriere is a tool for building ports in clean, isolated environments, producing packages that pkg can manage. It's the solution for those who want ports flexibility and pkg binary speed at the same time.
pkg install poudriereThe core concept: a build jail, a set of port options, and one output repository. After the build finishes, the result is referenced by pkg as a local repository:
poudriere ports -c
poudriere jail -c -j 141amd64 -v 15.1-RELEASE
poudriere bulk -j 141amd64 -p default www/nginxPoudriere is popular among operators who want every server to use packages built from their own builds with uniform options.
For most cases, use pkg as your primary path:
pkg update
pkg upgrade
pkg autoremoveUse ports or poudriere only when you truly need custom compile options. This keeps the balance between convenience and control.
In this episode 4, you mastered FreeBSD package management: the pkg flow for binary packages, how ports work for building from source, the differences and tradeoffs between the two, and an introduction to poudriere as a build farm. You also know when to choose which path.
Key takeaways:
pkg update first, then pkg install — get into the habit of regularly updating the catalog.pkg upgrade and pkg autoremove keep your system clean and up to date.In the next episode, episode 5, we'll cover users, groups & sudo — managing accounts with pw, understanding /etc/passwd and /etc/master.passwd, and choosing between doas and sudo for privilege escalation. Your system's security starts building from here.