Linux Disable and Remove X Windows (

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.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 13 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
13 comments… add one
  • Trey Blancher Jul 18, 2009 @ 15:37

    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?

  • 🐧 nixCraft Jul 18, 2009 @ 15:45

    @ 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 

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

    Hope this helps.

  • Trey Blancher Jul 18, 2009 @ 20:13

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

  • benzm Jul 18, 2009 @ 22:43

    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. : )

  • Skip Flem Jul 19, 2009 @ 1:19

    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

  • Solaris Jul 20, 2009 @ 8:01

    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 ?

  • 🐧 nixCraft Jul 20, 2009 @ 8:38

    @ 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.

  • Susinthiran Jul 22, 2009 @ 11:14

    Again we see how skillful you are on Redhat based systems :)


  • Danny Jul 23, 2009 @ 19:23

    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…

  • M.S. Babaei Aug 1, 2009 @ 3:28

    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

  • sam Nov 16, 2011 @ 2:52

    thanks a bunch.

  • Subhendu Jul 12, 2013 @ 11:49

    Thanks buddy,
    Nice instruction for disable X11 for security and performance.

  • virendra Jun 17, 2017 @ 12:37

    hi friends i want disabled X -Windows servers .
    anyone can help

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum