Linux Disable and Remove X Windows (

last updated in Categories , , , , , , ,

I revived my new Dell server pre installed with Red Hat Enterprise Linux server v5.2. However, my box boot with a GUI login system ( Gnome ). There is no reason to run X Windows on my dedicated mail and Apache web server. I only need ssh. How do I disable X login and windows without reinstalling the operating system to improve security and performance?

CentOS / RHEL 5.x / Fedora Linux comes with X Windows system called The X Window System implementation included with the system is called There is no need to run X on a dedicated server such as web server or mail server or file server. Root (admin) user can login via SSH or on the text console (or may be using KVM).

Disable X Windows at System Boot

The /etc/inittab file describes which processes are started at bootup and during normal operation. This file is used to start X windows system at boot by setting default run level to 5. Edit the file /etc/inittab using a text editor such as vi, enter:
# vi /etc/inittab
Find line:


Replace with:


Save and close the file. Restart the server. You can also drop to text mode by typing init command:
# init 3

Delete X Windows from the Server

To remove the X11 RPMs (all packages) from the server, enter:
# yum groupremove "X Window System"
Above will remove 100-150 packages from the server. This make sure no one can start X on server by typing startx at the shell prompt. This will result into more secure system. Since, your box is dedicated server for web or mail serving, it is safe to delete the software from the system.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

13 comment

  1. This is useful for Red Hat based systems. How do I achieve the same for Debian based systems such as Debian and Ubuntu? I understand I could remove it, but what if I need to disable it and not remove it?

  2. @ Trey
    Debian use /etc/rc2.d/*gdm or /etc/rc2.d/*kdm or /etc/rc2.d/*xdm to start GUI on a boot. All you’ve to do is move those files to somehwer else and you are done. You can also use

    update-rc.d gdm remove < == get rid of Gnome
    update-rc.d xdm remove <== get rid of Kde
    update-rc.d kdm remove <== get rid of other Xdm

    Reboot the server to test the changes. See this FAQ for more info.

    Hope this helps.

  3. OK, I guess I knew that, but I wasn’t sure it was that simple. Thanks for the clarification.

  4. this is good, but I get an error on an internal centos box that states “No group names X Window System exists” please let me know what I am doing wrong.

    Centos 5.2 updated a short while ago on an old P4 with lotsa ram and lotsa diskspace. : )

  5. Try:
    update-rc.d kdm remove <== get rid of Kde
    update-rc.d xdm remove <== get rid of other Xdm
    update-rc.d xdm remove <== get rid of other Xdm
    update-rc.d kdm remove <== get rid of Kde

  6. Vivek what about this situation: I have a server where users work remotely on Gnome, so
    I had to manually add xorg and gnome-core and gdm – I was highly recommended to add gdm to avoid the Gnome policy kit hell.

    This was done on a Ubuntu server 8.04 64 bit and is working fine.

    But when it boots I would like to see the text flowing not the gdm, any idea of how to achive this without removing gdm ?

  7. @ Solaris,

    Simply use update-rc.d or rcconf command to delete gdm service. It will not remove GDM but it will just disable it on boot. To remove GDM and you need to use apt-get.

  8. Some of those X libraries are useful to command-line programs, though. Like glib, for example, or GD. A web server is likely to use a lot of graphics libraries which may have been linked to X11, and I personally like to have an xterm available for remote management (why would I emulate one when I’ve got the real thing?). So, don’t be shocked if some of the stuff from the X Windows System group needs to be put back, depending on what’s actually being served. At least yum should prevent admins from breaking stuff… :)

    PS – I’ve always used telinit to change runlevels, even though they’re really the same program…

  9. I love the gentoo way:
    emerge -C x11-base/xorg-x11 x11-base/xorg-server

    also in gentoo runlevel 3-5 is called default and it’s the same:
    u can simply run:
    rc-update del xdm default

    Still, have a question? Get help on our forum!