If FreeBSD is the operating system, then /etc/rc.conf
is like its remote control. Through this file, you're telling the system:
“Hey, turn this on at boot time, will ya?”
Let’s break down what’s inside rc.conf
— don’t worry, you don’t need to be a wizard sysadmin to understand it.
What is /etc/rc.conf
?
/etc/rc.conf
is FreeBSD’s main configuration file for enabling services and setting basic system options. When the system boots, it reads this file to find out:
- What's your hostname?
- Which services should start automatically?
- Are you using DHCP or static IP?
- Should the firewall or SSH daemon start?
Spoiler alert: it won’t fix your life problems — just system ones.
Location and Format
The file is located at:
/etc/rc.conf
The format is super simple:
variable="value"
Example:
hostname="funbsd.local"
sshd_enable="YES"
ifconfig_em0="DHCP"
YES or NO
Most entries follow this format:
servicename_enable="YES"
or "NO"
-
"YES"
means start the service on boot. -
"NO"
means don’t start it. Duh.
Example:
ntpd_enable="YES" # enable NTP (for time sync)
mysql_enable="YES" # start MySQL at boot
How to Edit rc.conf
Use your favorite text editor:
sudo vi /etc/rc.conf
Hate vi
? Try:
sudo ee /etc/rc.conf
(ee
stands for Easy Editor — perfect for folks who don’t want to fight their keyboard.)
Sample Configuration
hostname="myserver"
ifconfig_em0="DHCP"
sshd_enable="YES"
ntpd_enable="YES"
ntpdate_enable="YES"
mysql_enable="YES"
firewall_enable="YES"
firewall_type="open"
Check Running Services
Want to know which services are currently enabled?
service -e
Adding or Disabling Services
Installed something (e.g., nginx) and want it to run at boot?
echo 'nginx_enable="YES"' >> /etc/rc.conf
Or the cleaner way:
sysrc nginx_enable=YES
Want to disable it?
sysrc nginx_enable=NO
Tips
-
Use
sysrc
to safely add/edit entries — it avoids typos and keeps the format clean. -
You can also use
/etc/rc.conf.local
to override settings without touching the main file. - Don’t put comments mid-line. Place them at the end.
sshd_enable="YES" # Enable SSH
/etc/rc.conf
is FreeBSD’s startup control center. With this file, you can:
- Turn services on or off at boot
- Set your hostname, network, and firewall
- Look like a hacker while just typing “YES”
0 Comments:
Post a Comment