Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In 10.10 upstart is being used instead of sysvinit.

It's possible to remove annoying upstart services which you do not want by removing the appropriate file in /etc/init/blah.conf

However, this seems a heavy handed approach. How do you correctly configure upstart to be able to selectively turn these services on and off via the command line?

As a practical example, the answers listed here to turn gdm off using rcconf no longer work: How do I prevent GDM from running at boot on Ubuntu?

share|improve this question
    
Nb. Apparently some versions of ubuntu have a 'services' item in the menu of the graphical desktop that allows this to be configured. That is not present on mine. I'm specifically looking for a command line solution. –  Doug Apr 3 '11 at 13:08
    
The most updated answer is on askubuntu. Read the comments too! –  Marcello Nuccio Aug 20 '11 at 17:07
2  
This is now documented in the paragraph Disabling a Job from Automatically Starting. –  Marcello Nuccio Aug 20 '11 at 17:14
    
@Marcello Hm... was there a point to saying that? The 'most updated answer' is still the same answer. remove the file or delete the first few lines of it manually. –  Doug Aug 22 '11 at 3:56
    
the newest solution is echo manual >> /etc/init/<service>.override, and this is mentioned only in the comments (and in the official documentation). I did not found it easily, that's why I mentioned it here. –  Marcello Nuccio Aug 24 '11 at 6:05

6 Answers 6

up vote 18 down vote accepted

If you look in /etc/init.d you will notice that any services that are configured through upstart are just symbolic links to /lib/init/upstart so removing them from /etc/init.d just removes the link - not the script.

If you want an interface to this you can install the chkconfig package (apt-get install chkconfig) which gives a useful command line tool:

# chkconfig --list
acpi-support              0:off  1:off  2:on   3:on   4:on   5:on   6:off
acpid                     0:off  1:off  2:off  3:off  4:off  5:off  6:off
alsa-mixer-save           0:off  1:off  2:off  3:off  4:off  5:off  6:off
anacron                   0:off  1:off  2:off  3:off  4:off  5:off  6:off
apache2                   0:off  1:off  2:on   3:on   4:on   5:on   6:off
apparmor                  0:off  1:off  2:off  3:off  4:off  5:off  6:off  S:on 
apport                    0:off  1:off  2:off  3:off  4:off  5:off  6:off
atd                       0:off  1:off  2:off  3:off  4:off  5:off  6:off
.... and so on ....

You can enable / disable services for specific run-levels (or just turn them on and off) with:

# chkconfig -s <service> <state/runlevels>

for example:

# chkconfig -s gdm off

to turn it off completely,

# chkconfig -s gdm on

to turn it on with the defaultsm or

# chkconfig -s gdm 34

to only turn it on for run levels 3 and 4.

You'll usually find this command on RHEL based systems (CentOS, Fedora, etc).

UPDATE

This is specific to Ubuntu and gdm / kdm / whatever.

When gdm starts up it calls an upstart config file /etc/init/gdm.conf

This file then references /etc/X11/default-display-manager to see if it is the default display manager for the system - if it is then it starts.

The /etc/X11/default-display-manager just contains:

/usr/sbin/gdm

You can replace this with another display manager, or remove the file entirely and it won't start gdm.

A line from the /etc/init/gdm.conf file:

[ ! -f /etc/X11/default-display-manager -o "$(cat /etc/X11/default-display-manager 2>/dev/null)" = "/usr/sbin/gdm" ] || { stop; exit 0; }

It's saying "If the file /etc/X11/default-display-manager doesn't exist, or if it doesn't contain /usr/sbin/gdm then exit"

share|improve this answer
    
That didn't work. Just like rcconf, chkconfig does not list gdm as a service to be started at any run level. Yet, restarting, it loads. chkconfig -s gdm off did not prevent it from starting. –  Doug Apr 5 '11 at 4:26
2  
There is a link here also suggesting that chkconfig is not the appropriate tool to use: ubuntuforums.org/showthread.php?t=1559266 –  Doug Apr 5 '11 at 4:35
    
I have never liked Ubuntu's startup - and Linux's in general. It has always seems so messy and kludgy. Give me FreeBSD's rcng any day. Anyway - specific to Ubuntu's display manager you have what my edit shows... –  Majenko Apr 5 '11 at 8:58
    
+1 for correct after edit with details for upstart. –  Doug Apr 27 '11 at 5:34

I've always found the sysv-rc-conf tool very helpful, it has a very nice & easy to use interface.

install it like this:

sudo apt-get update
sudo apt-get install sysv-rc-conf

use it like this:

sudo sysv-rc-conf
share|improve this answer
    
I dont think that works for upstart services though.. –  user01 Mar 9 at 19:52

Simply take a look at man 5 init and you will find a more appropriate solution. Short example: Say we have a service called "foobar", so there would be a file called /etc/init/foobar.conf with its upstart configuration. Now you don't want to remove that file, nor to modify it -- but neither you want this service to run? So place an override file next to it: /etc/init/foobar.override, containing (optionally the header with the description and) instead the start on / stop on lines you place a line with one word: manual. This way you tell upstart to basically use the foobar.conf, but override the startup definition to only start that service when manually enforced (via service foobar start in our example).

share|improve this answer

My recommendation would be to simply comment out all "start on" and "stop on" lines. That worked well for me when I ran "initctl show-config" to see if the automatic startup of my program I wanted was disabled.

share|improve this answer

Upstart is an event-driven init manager, and runlevels are not the primary mechanism for deciding when a service starts. Instead, services are started when all their dependencies are satisfied, which allows greater parallelism during boot, speeding up the boot process.

Using Ubuntu 11.04, I was able to disable GDM by editing the /etc/init/gdm.conf file, and removing all of the "start on" entries. Here is my pre-edit:

start on (filesystem
          and started dbus
          and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
               or stopped udev-fallback-graphics))
stop on runlevel [016]

Here is my post-edit:

start on
stop on runlevel [016]
share|improve this answer
1  
Correct; however, this is basically no better than just moving/removing the etc/init/gdm.conf file; I'm (still) amazed that manually editing the config file seems to be the only way to do this. –  Doug May 26 '11 at 1:16

Here's a solution:

http://ubuntuforums.org/showpost.php?p=9416839&postcount=3

@Matt Jenkins

I have never liked Ubuntu's startup - and Linux's in general. It has always seems so messy >and kludgy. Give me FreeBSD's rcng any day. Anyway - specific to Ubuntu's display manager >you have what my edit shows...

Arch Linux has a nice init system. However, systemd blows any other init system out of the planet.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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