How do I choose which way to enable/disable, start/stop, or check the status of a service?

Posted by Glyph on Ask Ubuntu See other posts from Ask Ubuntu or by Glyph
Published on 2012-10-11T05:01:29Z Indexed on 2012/10/18 17:25 UTC
Read the original article Hit count: 299

If I want to start a system installed service, I can do:

# /etc/init.d/some-svc start
# initctl start some-svc
# service some-svc start
# start some-svc

If I want to disable a service from running at boot, I can do:

# rm /etc/rc2.d/S99some-svc
# update-rc.d some-svc disable
# mv /etc/init/some-svc.conf /etc/init/some-svc.conf.disabled

Then there are similarly various things I can do to enable services for starting at boot, and so on.

I'm aware of the fact that upstart is a (relatively) new thing, and I know about how SysV init used to work, and I'm vaguely aware of a bunch of D-Bus nonsense, but what I don't know is how one is actually intended to interface with this stuff. For example, I don't know how to easily determine whether a service is an Upstart job or a legacy SysV thing, without actually reading through the source of its shell scripts extensively.

So: if I want to start or stop a service, either at the moment or persistently, which of these tools should I use, and why? If the answer depends on some attribute (like "this service supports upstart") then how do I quickly and easily learn about that attribute of an installed package?

Relatedly, are there any user interface tools which can safely and correctly interact with the modern service infrastructure (upstart, and/or whatever its sysv compatibility is)? For example, could I reliably use sysv-rc-conf to determine which services should start?

© Ask Ubuntu or respective owner

Related posts about command-line

Related posts about server