Starting Services

There is no great insight in this post, it is only to help me remember how to start services in Fedora and Ubuntu as I have both.  I used Fedora long enough to get used to the old chkconfig stuff, but now thats gone. Ubuntu never did that anyway. They are different, and I get confused about which new syntax to use on which system.

If somebody other than me ever reads this, be careful to check dates and versions before you believe anything I write. It will probably change. This is as of Fedora 16 and Ubuntu 12.04.

Fedora 16

Fedora uses systemd. You interact with it using systemctl, and for service x you refer to x.service: e.g. systemctl start smb.service

systemctl has start, stop, restart, status, enable (like the old chkconfig on), disable, is_enabled and list-units [type={service|target}].

The x.service files are in /etc/systemd/system/ (a few) and /lib/systemd/system/ (most of them) with the former overriding the latter. These two locations also contain files called xyz.target, with associated directories xyz.target.wants which contain symlinks to the .service files to be started for target xyz (e.g. basic, multi-user, etc). Targets are symbolic names for stages in stattup.

Installing a .service file means putting a link in /etc/systemd/system/xyz.wants pointing to the .service file. The .service file indicates which of the targets it is a “member” of, i.e. which target.wants directory to put the link in.

Ubuntu Oneiric

Ubuntu uses upstart, instead. There appears to be work going on to possibly change ubuntu (perhaps as early as 12.10) but that is based on 10 minutes reading the web, and I’m sure there is a lot of back and forth among the developers pro and con. As a simple end user, my life would be improved if I only had one system to learn.

In upstart the command line is initctl.

To start a service use initctl start x. Commands are start, stop, restart, reload, status, list. You can also still use the old syntax “service x start”, which will actually invoke initctl.

More conveniently still, you don’t have to say initctl. Just say “start x”, “stop x”, “status x” (except for list which requires you to say initctl list).

Upstart still employs the old Sys V mechanisms in /etc/rc* and /etc/init.d, but many of the “scripts” there are no longer scripts but symlinks to /lib/init/upstart-job. That process looks for “units” which are contained in /etc/init, such as /etc/init/smbd.conf. Since not everything has been migrated to upstart, those that haven’t still just have a script in init.d.