A quick reference for FreeBSD 15.1: updating the system and software with pkg, services, the pf firewall, networking and support dates.
Contents
Our images use FreeBSD 15.1. This release is supported until 31 March 2027, and the whole 15 branch until the end of 2029, so before 2027 you will need to move to the next release in the branch. Log in as the freebsd user and run administrator commands with sudo. The default shell is sh.
Updating the system and software
In the image, the base system is installed as packages, so one command updates both it and your software:
sudo pkg update
sudo pkg upgradeTo see how your system is set up, run pkg which /usr/bin/uname. If the answer is a FreeBSD-… package, the system is package-based, as in our image. If it says “was not found in the database”, it is a classic installation (for example from an ISO): update the base system with sudo freebsd-update fetch install and the software with pkg upgrade.
Take a server snapshot before updating. For moving to a new release, follow the release announcement on freebsd.org.
Software
sudo pkg install nginx | install |
sudo pkg delete nginx | remove; sudo pkg autoremove removes dependencies you no longer need |
pkg search word, pkg info | find a package, list installed packages |
sudo pkg audit -F | check whether your installed software has known vulnerabilities |
Services and logs
sudo sysrc nginx_enable=YES | start the service at boot |
sudo service nginx start | start it; also stop, restart, status |
service -e | which services are enabled |
/var/log/messages, /var/log/auth.log | the system log and the login log |
If the server’s clock drifts, turn on time synchronisation: sudo sysrc ntpd_enable=YES ntpd_sync_on_start=YES and sudo service ntpd start.
The pf firewall
pf is part of the system but is switched off. An example /etc/pf.conf that allows SSH, HTTP and HTTPS:
block in all
pass out all keep state
pass in proto tcp to port { ssh, http, https }
pass in inet proto icmpCheck the rules, then turn pf on:
sudo pfctl -nf /etc/pf.conf
sudo sysrc pf_enable=YES
sudo service pf startsudo service pf stop in the console.Network
The address and gateway are written to /etc/rc.conf when the server is created. To view them, use ifconfig and netstat -rn. After editing, apply the settings — preferably from the console rather than over SSH: sudo service netif restart && sudo service routing restart.
SSH
SSH is configured in a single file, /etc/ssh/sshd_config; FreeBSD has no sshd_config.d folder. To switch to key-based login and turn off passwords, see How to connect to your server over SSH.
Small things
- Daily emails to root. Every night FreeBSD gathers system reports and emails them to root. To save them to files instead, add the lines
daily_output="/var/log/daily.log",weekly_output="/var/log/weekly.log"andmonthly_output="/var/log/monthly.log"to/etc/periodic.conf. - Default editor. If vi is unfamiliar, the system includes a simple editor called ee. To make it open by default, add the line
export EDITOR=eeto~/.profile.
To check the system version, run freebsd-version.
Didn’t find the answer? Ask our support team — we’ll help.