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"
Best Answer
SysVinit works like this. Initialization scripts for each package are located in /etc/init.d. Links to those scripts are located in /etc/rcS.d and /etc/rc[0-6].d. These links start with either S (start) or K (kill) and a 2-digit number.
When the system boots and the SysVinit process starts, it looks in /etc/rcS.d and executes scripts starting with S, ordered by the number. (I believe it passes the "start" argument to the scripts, but I'm not sure.)
After all /etc/rcS.d scripts are processed, the system begins moving into a certain runlevel. In Ubuntu, booting to the normal desktop, the default runlevel is 2. So SysVinit looks in /etc/rc2.d and
If you've booted into Ubuntu's recovery mode instead, you'll be booting into runlevel 1. After all services are started, the system runlevel is officially set.
Finally, the system runs the /etc/rc.local script.
If you switch runlevels later, SysVinit runs the same basic process: it doesn't check /etc/rcS.d, but goes straight to processing the links in /etc/rcN.d (where N is whatever runlevel is being entered).
You could also write an Upstart script. I've written about Upstart previously, so check there for more details. Upstart scripts are kept in /etc/init; to write them, look over existing scripts to get a feel for how it works, and read the init(5) manpage.