Useful FreeBSD Commands

Are you like me and forget all the awesome things you learn about FreeBSD? My solution is to write this post and collect those commands and tricks in a single place.

freebsd-version

Linux and FreeBSD have /etc/os-release but only FreeBSD has the useful freebsd-version. I use it as freebsd-version -kru which shows, in order, the installed kernel version, running kernel version, and installed userland version.

freebsd-update

When you are ready to apply updates, you must use freebsd-update. I run it in three steps:

# freebsd-update fetch
# freebsd-update updatesready
# freebsd-update install

Apparently by running yes | freebsd-update it can be turned into an unattended update process.

When upgrading to new major version, e.g. from 12 to 13, use the -r flag/switch. More details Updating and Upgrading FreeBSD.

sysrc

The handy sysrc command safely edits rc files. I use it extensively in the Ansible roles I write.

pkg audit

Want to know if any of your packages are vulnerable? Run pkg audit -F as root where the -F flag/switch always fetches the latest vulnerabilities data.

pkg version

List all installed packages and their versions with pkg version. Add the -v flag/switch for verbose output.