What is the equivalent for "service servicename start" that Fedora/RHEL/CentOS uses for Debian/Ubuntu?

5,173

Solution 1

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

Solution 2

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).

Solution 3

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

Solution 4

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

Solution 5

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:
5,173

Related videos on Youtube

daniels
Author by

daniels

;)

Updated on September 17, 2022

Comments

  • daniels
    daniels over 1 year

    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?

  • Dave Drager
    Dave Drager almost 15 years
    I use /etc/init.d foo stop|start|restart as well.
  • Ophidian
    Ophidian almost 15 years
    Cribbing from a comment on another question (serverfault.com/questions/30701/how-to-enable-sshd-on-fedor‌​a-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.