FreeBSD Fundamentals · Module 04 of 14

Packages and the Ports Collection

Install, upgrade, audit and remove third-party software while understanding binary packages versus source-based ports.

Learning objectives

By the end of this module, you should be able to:

  • Use pkg safely for common software lifecycle tasks.
  • Explain when Ports differ from packages.
  • Audit installed third-party packages for known vulnerabilities.

Binary packages first

pkg is the normal operational choice for prebuilt third-party software. It maintains package metadata, dependencies and repositories.

Ports are build recipes

The Ports Collection provides source-build recipes and configurable build options. Mixing ad-hoc ports builds with repository packages requires care because dependency choices can diverge.

Worked examples

See the idea in practice.

Package lifecycle

pkg search nginx
pkg install -n nginx
pkg audit -F
pkg upgrade -n
  • -n previews changes for install/upgrade.
  • pkg audit -F refreshes vulnerability data and audits installed packages.
Hands-on lab

Lab — Install and inspect a small package

Goal: Install curl, inspect its metadata and remove it cleanly.

Before you start

  • Working internet access and package repositories.
STEP 1

Preview install

pkg install -n curl
STEP 2

Install and inspect

pkg install -y curl
pkg info curl
which curl
STEP 3

Audit and remove

pkg audit -F || true
pkg delete -y curl

Verify

  • pkg info succeeds after install and the package is absent after delete.

Expected outcome

  • Dependency operations are explicit and visible.

If it fails

  • If repository metadata is stale, use pkg update and inspect proxy/DNS if fetches fail.
Real-world connection

Package hygiene is part of system security and reproducibility.

Avoid these traps

Common mistakes

  • Running pkg upgrade blindly on critical systems without reviewing changes.
  • Assuming Ports and packages are identical deployment mechanisms.
Knowledge check

Can you explain it without looking back?

Open each answer only after you have tried to answer the question yourself.

1What does pkg upgrade do?

Compares installed packages with repository versions and upgrades as required.

2What does pkg audit -F do?

Refreshes vulnerability data and checks installed third-party packages.

3Why preview package changes?

To see dependency and removal consequences before modifying a production host.

My Learning

Record your progress for this module.

Progress is saved in this browser immediately. When you sign in to My Learning, it can also sync across devices.

Not started

Attempt the core lab and knowledge checks before marking the module complete.