Headaches over disabling/enabling services in Ubuntu?

UBUNTU 12.04 / Upstart 1.3 update

If you are trying to disable an Upstart script (something that can be started/stopped with "sudo start/stop service-name") , you should really use the method described by Luis Alvarado on AskUbuntu. Please use this to avoid editing scripts that are actually maintained in your repository.

But all of this is great for temporarily working with the service. How about a way to toggle the service until the user wants to toggle it again. Here is how. Since Upstart 1.3 we can tell a service to only start when we want to:

sudo sh -c "echo 'manual' > /etc/init/SERVICE.override" where the stanza manual will stop Upstart from automatically loading the service on next boot. You will be able to start the service manually afterwards. If you do not want this then you can simply delete the file. For example:

sudo sh -c "echo 'manual' > /etc/init/mysql.override" (Will put the MySQL service into "manual" mode. If you do not want this afterwards you can simply sudo rm /etc/init/mysql.override

I've recently found myself trying to disable a service in Ubuntu 10.10 -- problem was that every time I rebooted, it started anyways. The service I was trying to disable had changed from inetd to rc.d to Upstart during the past year or so, and I was looking all the wrong places.

The thing is, that you have to look for different ways that your service might be registered. Since Upstart has been only half-way integrated in 10.10, there are some different places you still have to look if the documentation isn't clear about how the service is launched (and usually it isn't). The following examples are for disabling services, as I think most services installed are automatically configured to run, and this is the task you'd be looking for...


The old System V style of doing things is to call the update-rc.d command to disable any start-up links located in /etc/rcX.d/

$ sudo update-rc.d NAMEOFJOB disable 0123456

You should always invoke this command, as it explicitly disables any start-up links that may reappear when Apt is doing updates to your programs. So don't just go and delete the start-up links!


Another place to look is the configuration folder of jobs. Because all of these .conf files are loaded and if they contain a description of when to be run, then that command will be executed. Look for something like this:

start on (filesystem  
        and net-device-up IFACE!=lo)  
 stop on runlevel [!2345]

In order to disable the job, you simply have to comment out the start on part, like so:

#start on (filesystem  
 #        and net-device-up IFACE!=lo)  
stop on runlevel [!2345]

inetd (OpenBSD style)

Another common convention is to rename the .conf file to .disabled as Upstart only loads .conf files.

Some services are started in OpenBSD style, ie. their descriptions are found in /etc/inetd.conf , the Internet superserver configuration database.

The reason inetd is still used is basically historical. Back in the days, it was desired to save memory by not loading programs until there was a need for them. One thing inetd is still used for is to load ancient TFTP servers when a UDP request is made on the TFTP port (see /etc/services for a list of port aliases in Linux). This description looks like so, and you simply have to place a '#' in front of the line to disable it.

tftp           dgram   udp4    wait    nobody /usr/sbin/tcpd /usr/sbin/in.tftpd --tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr --mcast-ttl 1 --maxthread 100 --verbose=5 /srv/tftp

Other places...

  • /etc/X11/Xsession.d/ is the folder where scripts to be run when the X server is started are kept. I've never needed to change anything here, and I wonder why some things are kept in here and not explicitly run when switching to runlevel 5...

  • Gnome services can be disabled if you navigate to System- >Preferences->Startup Applications. For instance, you can go here to disable the login sound (right?), Bluetooth manager (if you don't use bt), some Evolution Alarm (since you don't use Evolution, right?), Ubuntu One (don't use neither) and Checking for new hardware drivers (since I guess you don't constantly change hardware).