4

Is there some overview which Linux distribution comes with which (default) init system and uses which tool for starting/stopping services?

Is there some distribution independent way to start/stop/query a service?

  • /etc/init.d/xyz start does only work with system-v init systems
  • service xyz start is not available on every distribution (which distribution does (not) have this?)
  • case switching depending on available commands seems to be the only reliable way

Background: We need to write an installer for different Linux distribution which needs to restart/query services. Calling the service tool would be cool for that, but I'm not sure which distributions support this.

5

If this service is what you are installing, then you will probably need to know each distributions service management anyway as you should be writing your init scripts/config correctly for those platforms you want to support.

  • systemd - systemctl start xyz.service
    Fedora 15+, RHEL7, Arch, Debian 8+, Ubuntu 15+, openSUSE 12.3+

  • Upstart - service xyz start
    Ubuntu, Fedora 9+, RHEL6

  • SysV - /etc/init.d/xyz start
    RHEL5, Debian, Suse

  • OpenRC - /etc/init.d/xyz start
    Gentoo (supports Net/FreeBSD)

  • SMF - svcadm enable svc:/prefix/xyz
    Solaris, Opensolaris based (illumos, smartos etc)

  • rc - /etc/rc.d/xyz start
    BSDs

  • launchd - launchctl start xyz
    OSX

SysV is the Linux standard (/etc/rc.d/xyz) that most new init systems continue to support the scripts from, so that's your base point.

systemd is where Linux is heading

I'm not aware of a utility that can run on a lot of platforms but most config management software can do cross platform service management. Unfortunately that means you would need the config management software installed as well (or at least the underlying modules and runtime ruby/python). This is fine if you're managing the install on your own machines, as you could do all you install from the config tool. Not so good if you are trying to distribute software to anyone.

The following config management examples would interact with whatever the local default service manager is and start xyz if it is not already running. You don't need to be aware of anything more.

A Chef recipe can manage a service resource

service "xyz" do
  action :start
end

Puppet service

service { "xyz":
  ensure => "running",
}

Ansible service module

- service: name=xyz state=started

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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