nixCraft Poll

Topics

BSD start services

Posted by Vivek Gite [Last updated: April 11, 2007]

FreeBSD (and NetBSD) stores all service related scripts that stop, start or restart services under /etc/rc.d or /usr/local/etc/rc.d/ directory. From these directories, you can start/stop any network or other system related services. General syntax:

/etc/rc.d/service-name {start} {stop} {status} {reload} {forceXXX} {rcvar}

Where option can be use as follows,

Examples:

Start sshd service:

# /etc/rc.d/sshd start

Stop sshd service:

# /etc/rc.d/sshd stop

Restart sshd service:

# /etc/rc.d/sshd restart

However, service will not start, stop or restart if it is not configured in /etc/rc.conf file. For instance to restart sshd regardless of the current /etc/rc.conf setting, you can use forcerestart as follows:

# /etc/rc.d/sshd forcerestart

Or just start regardless of the current /etc/rc.conf setting

# /etc/rc.d/sshd forcestart

Or just stop regardless of the current /etc/rc.conf setting

# /etc/rc.d/sshd forcestop

More on /etc/rc.conf file
All freebsd services usually started automatically as specified in rc.conf. For example, enabling the SSHD daemon at startup is as simple as adding the following line to /etc/rc.conf:
sshd_enable="YES"

However, you can also use sysinstall command to add services that can start automatically as specified below:

1) Start sysinstall by typing sysinstall

# sysinstall 

2) Select Configure

3) Select Startup

4) Select the service you wish to start automatically by pressing space bar

5) When done select Ok and Exit to shell prompt

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Anonymous Says:

    Very informative I also find official Handbook quite helpful too

  2. Unknown Says:

    I don’t wanna troll but like to know who is using FreeBSD these days?

  3. Jason Says:

    Troll indeed. Take a look at netcraft. FreeBSD is alive and well in the server market.

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

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

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.