Where FreeBSD keeps its configuration (rc.conf and friends)

freebsd 15 / published / guide #27 / ≈ 5 min read

Coming to FreeBSD from Linux, the config layout looks similar but reads differently. There's no systemd, no /etc/default/, no NetworkManager. Almost everything the system does at boot is controlled by a small set of plain-text files in /etc, with one or two friendly commands to edit them safely. This is the map.

The big idea: /etc is the OS, /usr/local/etc is the packages

FreeBSD draws a hard line between the base system (the kernel and its core utilities — shipped together, updated together) and everything you install on top (packages from pkg or the ports tree).

That split shows up everywhere:

  • /etc/ — config for the base system (rc.conf, fstab, sshd_config, ssh keys, hostname, etc.)
  • /usr/local/etc/ — config for packages you installed (nginx.conf, postgresql, dovecot, etc.)

If you've been hunting around for an nginx config and only finding empty /etc directories — try /usr/local/etc/nginx/.

/etc/rc.conf — the most important file you'll edit

/etc/rc.conf tells the system: what name am I, what network interfaces should I bring up, what services should start at boot? It's just a list of shell-style KEY="VALUE" lines.

A minimal example:

hostname="seal"
ifconfig_em0="DHCP"
sshd_enable="YES"
ntpd_enable="YES"
ntpd_sync_on_start="YES"
powerd_enable="YES"

Three things to notice:

  1. Values are quoted strings. Even YES and NO — they're strings, not booleans. sshd_enable=YES without quotes will eventually bite you.
  2. YES/NO is the on/off switch for services. sshd_enable="YES" means the SSH daemon starts at boot.
  3. Interface names are part of the variable. ifconfig_em0, ifconfig_re0, ifconfig_igb0 — the suffix is your card's name. Find yours with ifconfig.

sysrc — the safe way to edit rc.conf

You can edit /etc/rc.conf with a text editor, but sysrc is safer: it parses the file, applies your change, and rewrites it cleanly. No accidental syntax breakage.

sudo sysrc hostname="seal"             # set
sudo sysrc sshd_enable="YES"           # set
sudo sysrc -x ntpd_enable              # delete a key
sudo sysrc -A                          # show all configured values
sysrc -n hostname                      # read one value (no sudo needed)

You'll see this command a lot in FreeBSD documentation. Get comfortable with it.

service — controlling daemons

service is what you use to start, stop, and check daemons. The names match what you wrote in rc.conf:

sudo service sshd status
sudo service sshd restart
sudo service nginx start
sudo service nginx stop

Two important variants:

  • service nginx start — only works if nginx_enable="YES" is in rc.conf.
  • service nginx onestart — runs it once without needing it enabled. Useful for testing a service before committing to "auto-start at boot."

If service nginx start says "Cannot run nginx," it usually means you forgot sysrc nginx_enable="YES" first.

sysctl — kernel parameters

While rc.conf controls services, sysctl controls kernel behaviour: networking knobs, memory limits, security policies. Hundreds of values, all readable with sysctl -a.

sysctl kern.maxfiles                          # read
sudo sysctl kern.maxfiles=200000              # write (live, lost on reboot)

To make a sysctl change persist across reboots, add it to /etc/sysctl.conf:

sudo nano /etc/sysctl.conf
kern.maxfiles=200000
net.inet.ip.forwarding=1     # enable IP forwarding (e.g., for a router or jails)

Reboot or run sudo /etc/rc.d/sysctl reload to apply.

/boot/loader.conf — boot-time settings

Some things can't be set after the kernel's already running — kernel modules to load, parameters that must be in place before the boot sequence starts. Those go in /boot/loader.conf:

zfs_load="YES"                   # load the ZFS module
nvidia_load="YES"                # load NVIDIA driver (if installed)
hw.usb.no_boot_wait=1            # don't wait for slow USB devices at boot
vm.kmem_size="2G"                # kernel memory size (for ZFS-heavy servers)

Changes here take effect on the next boot. There's no "reload" — the file is read once, by the bootloader.

/etc/fstab — what to mount where

If you've installed Linux, /etc/fstab looks familiar. Each line is a filesystem to mount at boot:

/dev/gpt/swap0   none   swap   sw            0  0
/dev/gpt/rootfs  /      ufs    rw            1  1
fdesc            /dev/fd  fdescfs  rw         0  0
proc             /proc    procfs   rw         0  0

On a default ZFS install you'll see very few entries — ZFS manages its own mounts. UFS systems have more.

Where packages put their config

Everything you install through pkg drops its config under /usr/local/etc/:

/usr/local/etc/nginx/nginx.conf
/usr/local/etc/postgresql/16/postgresql.conf
/usr/local/etc/dovecot/dovecot.conf
/usr/local/etc/rc.d/                  # service scripts for packages

This is the part that surprises Linux users the most. If you're looking for the config of a package and not finding it under /etc, walk down /usr/local/etc/.

Periodic — the daily emails

FreeBSD runs scheduled maintenance tasks every day, week, and month. They check for security updates, rotate logs, look for filesystem oddities, and email the results to root (locally — read with mail, or set up forwarding in /etc/aliases).

What runs is controlled by /etc/periodic.conf:

sudo nano /etc/periodic.conf

Most of the time the defaults are fine. The interesting knobs are toggles like daily_clean_tmps_enable="YES" or weekly_locate_enable="NO".

User management with pw

FreeBSD doesn't have useradd/usermod. It uses pw:

sudo pw useradd -n alice -m -G wheel -s /usr/local/bin/bash
sudo passwd alice
sudo pw groupmod wheel -m bob               # add bob to the wheel group
sudo pw usermod alice -s /usr/local/bin/zsh  # change alice's shell

Just like Linux's tools, but the flag layout is different. pw -h is your friend.

A quick map to keep nearby

  • /etc/rc.conf — services and boot-time variables (edit with sysrc)
  • /etc/sysctl.conf — kernel tunables that survive reboot
  • /boot/loader.conf — bootloader-time settings, kernel modules
  • /etc/fstab — filesystem mounts
  • /etc/hosts — local DNS overrides
  • /etc/resolv.conf — DNS servers
  • /etc/ssh/sshd_config — SSH server
  • /etc/periodic.conf — what the daily/weekly/monthly tasks do
  • /etc/make.conf, /etc/src.conf — knobs for building from source
  • /usr/local/etc/ — config for every installed package
  • /usr/local/etc/rc.d/ — service scripts from packages

The shortest possible summary

If you remember one command, remember sysrc. If you remember one file, remember /etc/rc.conf. Everything else fans out from there.

← back to index