Handling rc.conf(5) with sysrc

FreeBSD uses the traditional BSD boot system as opposed to the system used in Linux, i.e SysV.

This means that in FreeBSD, we have a directory called /etc/rc.d with a bunch of scripts that bring our system up and running. Alongside these scripts, there is a file used to control some configuration variables used at boot time:/etc/rc.conf

Since it is a very sensitive file, an unfortunate mistake while editing it can break havok if our system does not boot the next time. To avoid these kind of situations, there is a tool called sysrc. sysrc provides a way to edit rc.conf(5) safely and effectively.

In order to install the tool, just type:

<code>% portinstall sysrc</code>


<code>% cd /usr/ports/sysutils/sysrc &amp;&amp; make install</code>

The tool is written completely in sh so it does not need any external dependencies and it does not require compiling. With a simple invocation, it reports the current configuration of our system:

<code>$ sysrc -a
allscreens_flags: MODE_32
background_dhclient: YES
dbus_enable: YES
devfs_system_ruleset: localrules
dumpdev: /dev/ada0p3
hald_enable: YES
hostname: hammer
ifconfig_re0: DHCP
keymap: spanish.iso.acc.kbd
linux_enable: YES
moused_enable: YES
nisdomainname: NO
powerd_enable: YES
saver: daemon
sendmail_enable: NO
sendmail_msp_queue_enable: NO
sendmail_outbound_enable: NO
sendmail_submit_enable: NO
sshd_enable: NO</code>

Changing the value of a variable is easy (and safe):

<code>$ sysrc linux_enable=NO
linux_enable: YES -&gt; NO
$ sysrc linux_enable
linux_enable: NO</code>

Once we know about the existence of this utility it becomes indispensable in our installations of FreeBSD.