How to disable services in Ubuntu (using Upstart)

Ubuntu has been transitioning to Upstart for a long time now. In the early days one could disable a service only by renaming the job config file in /etc/init (to something that does not end in .conf) or modify the file so it won't start the job automatically.

In Ubuntu 11.10 (Oneiric) Upstart v1.3 was introduced with support for override files. This means that one can create a file as /etc/init/SERVICE.override (eg. with a single line containing the manual configuration directive) and it'll be preferred to the original /etc/init/SERVICE.conf file. Of course you can put a full Upstart configuration into an override file as well if you like Smile, but most probably you won't (although you might want to put a comment or author+description stanzas in the file explaining the reason for the override and maybe adding a timestamp, so you know when this override was introduced).

This provides an easy way to persistently disable an Upstart job without touching the original configuration file. Since there're a lot of Upstart jobs in Ubuntu and some of them are in required packages (i.e. in packages that you cannot get rid off easily), this method for disabling services is a necessity. To be honest, I don't know why it took so long to implement this. Shock

In Ubuntu 13.04 (Raring) Upstart 1.8 was introduced which includes another improvement (from Upstart v1.7): a number of additional locations are scanned for job configuration files. This includes both user directories and further system directories.

Currently (in v1.7 - v1.8) the following locations can provide Upstart jobs:
  1. The config file at /etc/init.conf
  2. The directory specified by the --confdir commandline option or (if not specified) the directory specified by the UPSTART_CONFDIR environment variable or (if not specified) the /etc/init directory.
  3. User config in the directory $XDG_CONFIG_HOME/upstart or (if it does not exist) in $HOME/.config.
  4. User config in the directory $HOME/.init (if it exists).
  5. System config in the directory at $XDG_CONFIG_DIRS/upstart or (if it does not exist) at /etc/xdg/upstart.
  6. System config in the directory at /usr/share/upstart/sessions.
In each directory *.conf files are being looked for ... and if a file exists, a *.override file with the same basename can override it's contents.

The above list defines the priority order too. I.e. when a job specification is found first (processing the list of directories), then job config files with the same basename will be ignored in the other directories.