Q. How do I disable services located at /etc/rc.d or /usr/local/etc/rc.d directory? For example I’d like to disable a service called /etc/rc.d/foo

A. FreeBSD services can be controlled by updating /etc/rc.conf file. The file rc.conf contains descriptive information about the local host name, configuration details for any potential network interfaces and which services should be started up at system initial boot time. You can edit file manually to remove entries. It is recommended that you use sysinstall utility to modify the /etc/rc.con file.

Advertisement

sysinstall utility

From the man page – The sysinstall utility is used for installing and configuring FreeBSD systems. It is the first utility invoked by the FreeBSD installation boot floppy and is also available as /usr/sbin/sysinstall on newly installed FreeBSD systems for use in later configuring the system. To start sysinstall login as root and enter:
# sysinstall
Select Configure (Do post installation menu) > Startup (configure system startup options) > Use [Space] or [Enter] key to select / deselect services / items from a menu > Ok to save the changes.

FreeBSD sysinstall to disable services
(Fig. 01: FreeBSD sysinstall utility in action)

Manually edit /etc/rc.conf

You can manually edit / update /etc/rc.conf file to enable or disable services:
# vi /etc/rc.conf
To disable sendmail at boot time, find line that read as follows:
sendmail_enable="YES"
With:
sendmail_enable="NONE"
Close and save the file.

Usually all services accepts – YES and NO parameters to enable or disable services. The correct way to figure out service parameter is by reading rc.conf man page. See rc.conf man page for more information:
man rc.conf
man rc

Updated for accuracy.

πŸ₯Ί Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🀠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

7 comments… add one
  • Sam Gaw Apr 8, 2008 @ 0:51

    To disable Sendmail on FreeBSD you need to use the following in rc.conf:


    sendmail_enable="NONE"

    not


    sendmail_enable="NO"

  • ddb May 16, 2008 @ 13:38

    Hello,


    sendmail_enable="NONE"

    is to completely disable the sendmail service. Use

    sendmail_enable="NO"

    to bind it to the localhost only. I prefer it that way.

  • πŸ›‘οΈ Vivek Gite (Author and Admin) nixCraft May 16, 2008 @ 14:45

    ddb and sam,

    Thanks for pointing out information. The faq has been updated.

  • Asnawi May 16, 2008 @ 23:41

    when I edit rc.conf, there was mistake I’v made.

    ifconfig_xl0=”inet 10.2.1.147 netmask 255.255.255.248

    As you can see above. I forgot to write ‘”‘.

    then when I reboot my computer, this message appear:

    etc/rc.conf: 10 : syntax error : Unterminated quoted string
    Enter full pathname of shell or RETURN for /bin/sh :

    what shoul I do?
    It have not been resolved yet.
    That make me mad…

  • πŸ›‘οΈ Vivek Gite (Author and Admin) nixCraft May 17, 2008 @ 11:05

    Asnawi,

    Just type /bin/sh and enter it will boot the system. Mount the partition if not mounted and edit /etc/rc.conf file. Reboot again.

  • eko Oct 20, 2008 @ 9:49

    # Asnawi Says:
    May 16th, 2008 at 11:41 pm

    when I edit rc.conf, there was mistake I’v made.

    ifconfig_xl0=”inet 10.2.1.147 netmask 255.255.255.248

    As you can see above. I forgot to write β€˜β€β€˜.

    then when I reboot my computer, this message appear:

    etc/rc.conf: 10 : syntax error : Unterminated quoted string
    Enter full pathname of shell or RETURN for /bin/sh :

    what shoul I do?
    It have not been resolved yet.
    That make me mad…

    u must enter one more time untul show # symbol

    then type mount -t ufs -a enter

    so edit rc,conf with editor default on your freebsd machine ee or vi

  • SIFE Dec 5, 2009 @ 6:44

    salamo alikom
    @Asnawi
    boot in single user(type 4 at menu boot) then mount your ufs partitions :
    mount -a -t ufs
    now edit your rc.conf :
    ee /etc/rc.conf
    then fix system errors if exist
    fsck -y
    finally reboot your system and you will get is :
    reboot

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.