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:

% portinstall sysrc


% cd /usr/ports/sysutils/sysrc && make install

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:

$ 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

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

$ sysrc linux_enable=NO
linux_enable: YES -> NO
$ sysrc linux_enable
linux_enable: NO

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


speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*Required Fields