How to disable GDM from being automatically started?

For Ubuntu 18.04 this worked for me:

Disable gdm
This will prevent gdm from loading on boot and login is via console.

systemctl set-default multi-user.target

Using this method, gdm can still be started manually with systemctl start gdm

Check the systemd default with

systemctl get-default

Usually this will be graphical.target and can be reverted with systemctl set-default graphical.target

Source: https://wiki.debian.org/GDM#systemd


In recent versions of Ubuntu, gdm has been replaced with lightdm - this is why you don't have a gdm.conf. To set lightdm to be started manually, create an 'override' file for its init configuration:

echo 'manual' | sudo dd of=/etc/init/lightdm.override

(this just creates a file, called /etc/init/lightdm.override, containing a single line that says manual)

This way, lightdm will only be started when you invoke:

sudo service lightdm start

and to stop it:

sudo service lightdm stop

just want to share , may be it become helpful to any one .

I installed Ubuntu Server 12.04 and later installed graphical interface kubuntu-desktop

now when i wanted to disable graphical startup/login I tried all the options

/etc/default/grub .. making the entry GRUB_CMDLINE_LINUX_DEFAULT="text" in place of "quiet splash"

update-grub

update-rc.d -f ldm remove
update-rc.d -f kdm remove
update-rc.d -f gdm remove

as well as

echo 'manual' | sudo tee /etc/init/lightdm.override

Nothing worked. Then I edited the /etc/init/kdm.conf , and added 2 default runlevel to and runlevel [!026]

stop on runlevel [0126]
#================================================================
#start on ((filesystem
#           and runlevel [!026]
#           and started dbus
#           and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
#                or stopped udev-fallback-graphics))
#          or runlevel PREVLEVEL=S)
#
#stop on runlevel [0126]
#================================================================

It worked.