How to disable X server autostart in Debian Jessie?

106,203

Solution 1

The disable didn't work because the Debian /etc/X11/default-display-manager logic is winding up overriding it.

In order to make text boot the default under systemd (regardless of which distro, really):

systemctl set-default multi-user.target

To change back to booting to the GUI,

systemctl set-default graphical.target

I confirmed those work on my Jessie VM and Slashback confirmed it on Stretch, too.

PS: You don't actually need the X server on your machine to run X clients over ssh. The X server is only needed where the display (monitor) is.

Solution 2

you can also add systemd.unit=multi-user.target to the kernel command line, if you can't access the running system.

Solution 3

I don't know much about Debian, but on my Ubuntu 14.04 laptop, here is the standard procedure I use when I want to disable X and boot to command prompt for troubleshooting:

  1. Edit the file /etc/default/grub in superuser mode and set GRUB_CMDLINE_LINUX_DEFAULT="text"

Optionally, also uncomment this line: #GRUB_TERMINAL=console and then do sudo update-grub. The machine will boot in text mode.

  1. To start the graphical interface from there, you then do sudo service lightdm start #could be gdm or startx in some situations

Source: https://askubuntu.com/questions/52089/how-do-i-boot-to-a-command-line-interface-instead-of-a-gui

Solution 4

I had to do this:

systemtcl disable *dm

where * is a g or a k maybe an x.

Share:
106,203

Related videos on Youtube

Sai Kurogetsu
Author by

Sai Kurogetsu

Updated on September 18, 2022

Comments

  • Sai Kurogetsu
    Sai Kurogetsu over 1 year

    I have a remote machine running Debian 8 (Jessie) with lightdm installed. I want it to start in no-GUI mode, but I don't want to remove all X-related stuff to still be able to run it though SSH with the -X parameter. So how to disable X server autostart without removing it?

    I tried systemctl stop lightdm, it stops the lightdm, but it runs again after reboot. I also tried systemctl disable lightdm, but it basically does nothing. It renames lightdm's scripts in /etc/rc*.d directories, but it still starts after reboot, so what am I doing wrong? And I can't just update-rc.d lightdm stop, because it's deprecated and doesn't work.

    • Admin
      Admin about 8 years
      Running X stuff through ssh doesn't require an X server installed on the machine. (It just requires the X client libraries). Do you really want an X server installed? [AFAIK, you've found a bug—the disable should have worked. Of course that's hardly an answer...]
    • Admin
      Admin about 8 years
      @derobert Oh, so... I think I don't need the X server in that case. It's still more of a workaround than a solution, but thanks. Can I safely remove the lightdm and all xorg-server-* packages or should I keep something, e.g. xorg-server-input-* or video drivers?
    • Admin
      Admin about 8 years
    • Admin
      Admin about 8 years
      @kurogetsusai you can remove lightdm and xorg-server-*. You really just need to keep xauth (recommended by openssh-server) and any libraries your X clients depend on. You probably need some fonts as well.
  • jlh
    jlh about 7 years
    +1 for pointing out X isn't required to run X clients over SSH
  • emile boyer
    emile boyer almost 7 years
    of course * is a "g" or a "k" maybe "x"
  • Valentin F.
    Valentin F. over 6 years
    Works on my Stretch VM.
  • ransh
    ransh over 6 years
    works but there is still xterm terminal, can't get rid of it.
  • derobert
    derobert over 6 years
    @ransh Sounds like you should ask your own question. Reference this one in your question and also explain what you mean by it works—I'm not sure how you still have an xterm popping up if X isn't starting. Also anything that might be different about your system.
  • Juha Untinen
    Juha Untinen over 6 years
    Didn't work in Ubuntu 16.04. It still boots automatically to gnome.
  • Prahlad Yeri
    Prahlad Yeri about 6 years
    Did you try uncommenting the GRUB_TERMINAL=console and also update the grub?
  • Juha Untinen
    Juha Untinen about 6 years
    Yes. I had to do this, which is mentioned in the accepted answer: systemctl set-default multi-user.target
  • Sadi
    Sadi almost 6 years
    you can user systemctl get-default to know what is the current one. very useful for remote server.
  • clearlight
    clearlight almost 5 years
    Wow. Great answer, thanks for pointing out -X works w/o XServer on host
  • Lawless Leopard
    Lawless Leopard about 4 years
    This is actually a better answer, since in Debian the "startx" is triggered by the display manager at boot. The display manager itself is managed (enabled at boot) by systemd. IMHO, the right way to disable x-server at boot would be to disable the Display Manager via systemd. Although I would personally use something along the lines of : $ sudo systemctl disable display-manager.service
  • Daniel
    Daniel about 4 years
    Also works for Ubuntu