Manage FreeBSD Ports

The FreeBSD Ports and Packages Collection offers a simple way for users and administrators to install applications. There are currently 22776 ports available.

To fetch the FreeBSD Ports tree for the first time, as root:

# portsnap fetch extract

Install portmaster to manage your ports without external databases or languages:

# cd /usr/ports/ports-mgmt/portmaster

# make install clean

To list all outdated and installed packages from the FreeBSD Ports tree:

# pkg_version -l '>'

(Packages that appear on the left of the > sign are outdated, and may be updated from the sources provided online.)

/usr/ports/UPDATING describes various issues and additional steps users may encounter and need to perform when updating a port, including such things as file format changes, changes in locations of configuration files, or other such incompatibilities with previous versions.

# less /usr/ports/UPDATING

Then, to upgrade all packages/ports:

# portmaster -Da

To update your packages in the future:

# portsnap fetch update

# pkg_version -l '>'

# less /usr/ports/UPDATING

# portmaster -Da

portmaster can also remove stale distfiles with the --clean-distfiles option. To clear old distfiles for all ports and automatically confirm their deletion, use the -t and -y flags respectively, i.e.,:

# portmaster -t -y --clean-distfiles

I perform the following set of commands when a significant error gets introduced into the ports tree:

# portmaster -dys --clean-distfiles

# portmaster -vy --check-depends

Also, if I need to rebuild a specific port and all of its dependencies, I use:

# portmaster -fR www/firefox