Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

What is the equivalent for "service servicename start" that Fedora/RHEL/CentOS uses for Debian/Ubuntu?
I've just read on some question here on serverfoault that using /etc/init.d/service is obsolete, so what's the correct way on Debian?

share|improve this question

8 Answers 8

up vote 10 down vote accepted

I don't know about the "correct" way, but I always use invoke-rc.d, so e.g. to restart MySQL:

sudo invoke-rc.d mysql restart
share|improve this answer

You can always just invoke the startup scripts directly (e.g., /etc/init.d/foo restart). This works on RedHat variants as well, although the path is slightly different there (/etc/rc.d/init.d, although I believe /etc/init.d is a symlink to it as well).

share|improve this answer
1  
I use /etc/init.d foo stop|start|restart as well. –  Dave Drager Jun 24 '09 at 16:14
2  
Cribbing from a comment on another question (serverfault.com/questions/30701/how-to-enable-sshd-on-fedora-11), directly calling /etc/init.d/servicename is discouraged on Fedora/Red Hat systems. You also don't necessarily get the same environment provided to the scripts as you would using the /sbin/service script (e.g. on SELinux Gentoo you need to use run_init instead of /etc/init.d to get things to start in the correct security context. –  Ophidian Jun 24 '09 at 16:23

all most every distro has /etc/init.d/service ****** {start|restart|reload|stop}

share|improve this answer

The same service <servicename> start works for me in Ubuntu 9.04. It is in the sysvinit-utils package.

share|improve this answer

Using /etc/init.d/foo on RedHat can cause problem if selinux is activated because the script should not set up the context correctly. The service command always works on selinux enabled RHEL.

share|improve this answer

I suggest that you read about Upstart:

http://upstart.ubuntu.com/

http://www.linux.com/archive/feature/125977

http://www.netsplit.com/category/tech/upstart/

It is used on:

  • Ubuntu 6.10 and later
  • Fedora 9 and later
  • Debian (as an option)
  • Nokia's Maemo platform
  • Palm's WebOS
share|improve this answer

Yep, that's what I use too. /usr/sbin/invoke-rc.d is the way to go.

share|improve this answer

Whatever about on Redhat systems, /etc/init.d/service is still the norm on debian derivatives.

share|improve this answer

Your Answer

 
discard

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.