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:

  • So, you had Ubuntu desktop, post-installed Xubuntu, but don't want the default Xubuntu graphical session, but only want to start X manually?
    – belacqua
    Commented Jun 16, 2012 at 18:44
  • Thank you +Jorge Castro. I've already read both articles before but both works on gdm.conf but I don't have gdm configuration on this box.
    – josircg
    Commented Jun 16, 2012 at 19:04
  • Thanks for replying belacqua. No. It's Ubuntu Server. That's exactly what I want: start X just on certain ocasions.
    – josircg
    Commented Jun 16, 2012 at 19:07
  • I am wondering with Xubuntu don't have a gdm.conf - this should be the root of all my questions.
    – josircg
    Commented Jun 16, 2012 at 19:12
  • Also see askubuntu.com/questions/6357/dont-start-xserver
    – belacqua
    Commented Jun 16, 2012 at 19:36

6 Answers 6


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
  • 3
    Wouldn't it be easier to just type echo manual >> /etc/init/lightdm.override as root? Commented Jun 8, 2013 at 5:53
  • 4
    @B1KMusic: sure; but then you have to do an extra command to get the root shell. I prefer using sudo and running the absolute minimum amount of stuff as a privileged user as possible (in this case, running a bash as root, vs. running dd as root) Commented Jun 10, 2013 at 0:55
  • This is a silly reason to use a very potent tool like dd. It's pretty easy to fat finger it (like pressing tab in the middle of light) and clobber an important file. Commented Nov 1, 2015 at 5:57
  • @RobRussell: how is that any different to providing a filename to any command? The advantage of using dd here is that you're only running one single (and simple) process as root, rather than an entire shell. Commented Nov 2, 2015 at 2:56
  • It's different in that dd can have very different results depending on the mistake they make. The goal is to get a line of text into a file. Text editors are made for that. If the user follows these instructions they don't see the file when you're done writing. If they want to go back and edit that file or look at the contents of it then they have to use a completely different command. I think most people would think to use an editor here (nano, gedit, vi, etc). Commented Nov 3, 2015 at 3:43

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-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.

  • Had same experience. This also worked on /etc/init/gdm.conf
    – Donn Lee
    Commented Aug 27, 2015 at 16:13

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.


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


The following is for Ubuntu Server 12 LTS

First you need open a real term with CTRL+ALT F1


Stop gdm with:

$ sudo service gdm stop

Remove gdm you don't need it at all on a server.

$ sudo apt-get remove gdm 

Set next boot runlevel with.

$ sudo telinit 3

Without gdm you will need to install xinit if you want to still be able to run gui based apps without the gdm window manager.

$ sudo apt-get install xinit

Reboot to runlevel 3.

$ sudo reboot

To run a GUI or desktop after reboot do.

$ startx 

This will start your gnome session as normal.

When finished simply logout of your desktop to and drop you back to a level 3 term.

Also you can now start individual apps without a desktop too like:

$ startx nautilus

or privileged with

$ startx sudo synaptic

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .