How to disable X or GUI on boot in Debian

This tutorial will explain how to disable X or GUI on boot in Debian

First get the root shell by entering the following at the boot prompt:

boot: Linux vga=normal s

Here, Linux is the label for the kernel image you are booting; “vga=normal” will make sure lilo runs in normal VGA screen, and “s” (or “S”) is the parameter passed to init to invoke single-user mode. Enter the root password at the prompt.

There are few ways to disable all the X starting daemons:

run update-rc.d -f ?dm remove ; update-rc.d ?dm stop 99 1 2 3 4 5 6 .

Example

For gnome

run update-rc.d -f gdm remove ; update-rc.d gdm stop 99 1 2 3 4 5 6 .

insert “exit 0” at the start of all /etc/init.d/?dm files

Example

For gnome edit /etc/init.d/gdm file

#vi /etc/init.d/gdm

add the following line in the first line

exit 0

Save and exit the file

rename all /etc/rc2.d/S99?dm files to /etc/rc2.d/K99?dm

Example

For Gnome

mv /etc/rc2.d/S99gdm /etc/rc2.d/K99gdm (may be more file)

remove all /etc/rc2.d/S99?dm files

rm /etc/rc2.d/S99gdm

run :>/etc/X11/default-display-manager

Here, number in rc2.d must correspond to the runlevel specified in the /etc/inittab. Also ?dm means that you need to run the command multiple times by substituting it with all of the xdm, gdm, kdm, and wdm.

Only the first one in the list is “the one true way” in Debian. The last one is easy but only works on Debian and requires you to set the display manager again later using dpkg-reconfigure. Others are generic methods to disable daemons.

You can still start X with the startx command from any console shell.

Sponsored Link

8 thoughts on “How to disable X or GUI on boot in Debian

  1. Perhaps the easiest way to manage start up services and run levels in Debian is with the use of either/both sysvconfig and sysv-rc-conf. sysv-rc-conf allows the admin to easily select/deselect services for each runlevel, while sysvconfig is cruder and allows the admin to select/deselect services, the changes being applicable to all runlevels. Both are ncurses applications and very simple to use. They’re in main.

  2. Nice, but you could also set the initdefault to 2 (in /etc/inittab)

    # The default runlevel.
    id:2:initdefault:

    Note that when setting inittab to 2, deamons stratings at > 2 are not started.

  3. Runlevel 2 in Debian still starts all kinds of services such as GDM (on a machine with a desktop environment), hal, dbus, cups etc etc. because all the multi-user runlevels are by default identical, or perhaps ‘awaiting configuration’. This can be checked on a default install.

    In each and every one of the start up scripts in /etc/rc#.d/ you’ll find the line ‘# Default-Start: 2 3 4 5’

    You can edit inittab or grub’s menu.lst to set runlevel 2 or 3 or 4 or 5 but you won’t see any difference unless you also edit those scripts, as you describe above. sysv-rc-conf is a really simple effective way to present and manage the runlevels. The only time I can see that manually editing/renaming the individual scripts has an advantage is if you need to change the sequence of service start ups within a runlevel, which is quite unusual.

  4. You can use this command for disable a script on runlevel :
    # update-rc.d -f gdm remove

  5. Or, if you just need to temporarily disable runlevel 5, you can get rcconf from the repositories and type it in bash to disable GDM/KDM from starting on next reboot. I use it primarily to install ATI and Nvidia drivers. It’s a very handy tool.

  6. In case someone else stumbles upon this like I did, some 7 years after the fact…
    In Debian 8 you I also needed to edit /etc/init.d/.depend.start as follows:
    + delete the entire line beginning gdm3:
    + delete all other references to gdm3

Leave a comment

Your email address will not be published. Required fields are marked *