How to disable X or GUI on boot in Debian
Posted by Admin on March 31st, 2009
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
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.


March 31st, 2009 at 3:47 pm
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.
March 31st, 2009 at 6:13 pm
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.
April 1st, 2009 at 9:23 am
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.
April 8th, 2009 at 12:36 pm
You can use this command for disable a script on runlevel :
# update-rc.d -f gdm remove
April 8th, 2009 at 4:41 pm
Riri: you could even read the article
April 9th, 2009 at 6:37 am
Ok, sorry
April 11th, 2009 at 8:24 am
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.