How to Update FreeBSD and Installed Packages

Print This Post Print This Post

FreeBSD has two separate components that can be updated: the core OS with freebsd-update and third party software with pkg and portmaster.
Security updates for the core and most popular packages are listed here as they come out.

Updating the core with freebsd-update

The first step is to check for updates. With elevated privileges, run:

freebsd-update fetch

When the process is complete, run:

freebsd-update install

If any updates are available they’ll be installed. In many cases you’ll be prompted to restart the machine and run freebsd-update again to complete the update.

Updating FreeBSD with freebsd-update

Updating packages with pkg

If you’ve installed packages with pkg, you update them with the same utility.
You can check for updates with a single command. Run:

pkg upgrade

Checking for software updates with pkg

If you’ve installed packages with the ports system, do not update them with pkg. Any compile time changes will be overwritten. Update them with portsnap and portmaster.
To prevent a package from being updated with pkg, run:

pkg lock packagename

Updating packages with portmaster and portsnap

If you’ve installed packages with the ports system, two utilities are used – portmaster and portsnap.

The first utility, portsnap, will update the local copy of the ports tree. Just run:

portsnap auto

After the process is completed, packages need to be scanned for and updated with portmaster. Do this with:

portmaster -a

Checking for software updates with portmaster

After each package is updated you’ll be asked if you want to delete a backup of the old package. Unless you have a good reason not to, you should.