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?

3 Answers 3


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.


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.


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.

  • 4
    Debian-based systems have 'invoke-rc.d' which fills the same roll as service.
    – Zoredache
    Nov 17, 2009 at 19:23
  • 1
    There really should be a distribution-independent way of doing this. Nov 17, 2009 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .