Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Whenever I need to restart Apache on my RHEL VPS, I type sudo /sbin/service httpd restart. However I notice a lot of articles suggest using sudo /etc/init.d httpd restart.

Is there any difference? If there is, when I should use each one?

share|improve this question
up vote 16 down vote accepted

From the man page:

service runs a System V init script in as predictable environment as possible, removing most environment variables and with current working directory set to /.

It then calls the init.d script. So they both accomplish the same thing, except calling the script via /sbin/service just ensures that some environment variables in your shell don't screw up the init.d script.

share|improve this answer

Using /sbin/service is good because it gives the daemon a fresh environment to work in, without any potentially-annoying environment variables getting in the way and causing havoc. At least, that's the rationale for requiring it at work; I've always used the init scripts directly on my other-distro machines and it hasn't caused a visible problem, but I'm assured that there was a real problem that /sbin/service is working around. Perhaps RHEL systems just have more crap laying around in the default environment.

share|improve this answer

My advice would be to use whatever you want whenever you're actually logged in to the machine, and use /etc/(init.d|rc.d)/daemon-name if you are scripting, the reason being the latter is generally more portable. IIRC, the only distros that come with /sbin/service in the base packages install are RH-flavored, i.e. RHEL, CentOS, Fedora. My Debian systems for example do not have this script, however this may not matter for your environment.

share|improve this answer
Debian-based systems have 'invoke-rc.d' which fills the same roll as service. – Zoredache Nov 17 '09 at 19:23
There really should be a distribution-independent way of doing this. – Sam Halicke Nov 17 '09 at 20:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.