Disable GUI in Linux

Have you ever come across a situation when you wanted to disable GUI in your Linux box? Well I have. I just got a brand new GPU server running Ubuntu 10.04 and as users at my lab are supposed to submit jobs to the machine remotely, I don’t actually need GUI running on it. Moreover, GUI consumes a lot of system resources which can be put to better use someplace else and there is always the threat of some security holes when you’re using X. If you happen to be running Ubuntu or another Debian based machine you will need to do this:

# update-rc.d -f gdm remove

This command does require root privileges. Also, this command assumes you are running GNOME. If you are running KDE it would look like this:

# update-rc.d -f kdm remove

If you are running XFCE, it will look like this:

# update-rc.d -f xdm remove

To load the GUI for the duration of a logged in session, use this command:

startx

If you later decide that you do want the GUI to be running all the time, use this command to do so:

# update-rc.d -f gdm defaults

Switch gdm for kdm or xdm as appropriate.

For other Linux distribution, you need to edit the file /etc/inittab

Go to the line that says:
id:5:initdefault:

Change the 5 to a 3
id:3:initdefault:

All you’re doing is changing the default run level from 5 to 3

And for Ubuntu that has grub2 (10.04 for eg): Edit /etc/default/grub
Replace
GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”
with
GRUB_CMDLINE_LINUX_DEFAULT=”text”

And uncomment the line
#GRUB_TERMINAL=console
to enable console login

then source the file to produce /boot/grub/grub.cfg configuration file sudo update-grub2

Leave a Reply