How to disable GDM from being automatically started?

After Ubuntu Server 12.04 installation, I installed Xubuntu just to have a minimal GUI:

sudo apt-get install x-window-system-core
sudo apt-get install --no-install-recommends xubuntu-desktop gparted

But now I want to start X just on certain ocasions. Before 12.04, I just issue:

sudo update-rc.d -f gdm remove

But this command does not work anymore.

How can I stop X from init on Ubuntu 12.04 ? And how can I start it when I need it ?

I have tried both of these questions but I don't have a gdm.conf:

  • Disable GDM on ubuntu netbook remix
  • How do I disable GDM and Graphical User Selection?

Solution 1:

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

Solution 2:

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

Solution 3:

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.

Solution 4:

I installed Ubuntu Server 12.04 on a netbook, mainly because I'm more of a fan of CLI then I am of GUI, but wanted a light GUI for small things. I installed LXDE, not Lubuntu, but it would start LXDM, the login manager for LXDE. I looked all over and tried many things to get this to stop loading LXDE. After looking at this question and answer, I found a good way of stopping it for LXDE.

Instead of adding a file similar to lightdm.override, I was looking in /etc/init and found a file called lxdm.conf. After looking through the file, mainly because I was curious, I found that this is the file that I needed, or didn't need. After closing the file, I renamed it

    sudo mv /etc/init/lxdm.conf /etc/init/lxdm.conf.bak

I renamed it instead of removing it in case it caused problems, but so far I can't tell any problems from renaming this file, so it should be safe to remove.

I don't know about other DE's but this worked for me with LXDE.

Solution 5:

Check systemctl get-default.

If the output is graphical.target, then set it to multi-user.target with systemctl set-default:

systemctl set-default multi-user.target

Reference this link for more on systemd-targets: 10.3. Working with systemd Targets