I recently received a question from a reader who said they’d installed GNOME on one of their data center CentOS 7 machines (so they could get the platform configured to their liking). But they wanted to then remove the GUI interface for the sake of security and to ensure the OS wasn’t wasting precious resources on a now-unnecessary GUI. The default response from many a Linux admin might be something akin to, “Why not just learn the command line for admin purposes?” And that’s a great response. However, some admins are migrating from Windows and are accustomed to a GUI interface. If a GUI is what they need to help them move to Linux, more power to them. And this particular administrator understanding the need to remove the GUI shows he is aware of the penalty that might accompany having such an interface on a server (might being the operative term).

The answer to the question of removal is surprisingly easy, but only when you know the specific command to do handle the removal.

The install

Before we get into the command to remove, let’s refresh our memory on how to install. This is equally as easy. With three simple commands you can install GNOME, set it up to start a graphical login, and reboot. Those commands are:

sudo yum -y groups install "GNOME Desktop"
sudo systemctl set-default graphical.target
sudo reboot

That’s all there is to it. Upon reboot you should see the graphical login screen awaiting your input.

You could also go the manual route by adding an .xinitrc file in your home directory (instead of making the graphical login screen the default, as done above with the sudo systemctl set-default graphical.target command). To do this, issue the command:

echo "exec gnome-session" >> ~/.xinitrc

Now when you want to start GNOME, just issue the command startx.

SEE: Server deployment/migration checklist (Tech Pro Research)

The removal

Now we answer the question: How do you remove GNOME from CentOS 7? Stripping GNOME from your server can be handled with a single command:

sudo yum groupremove "GNOME Desktop"

If, on the off-chance you also created an .xinitrc file in your ~/ directory, you may want to remove it with the command rm ~/.xinitrc.

You might also want to issue the command;

sudo yum grouplist

The above command will list out all of the groups you have installed on your system (Figure A).

Figure A

SEE: 20 quick tips to make Linux networking easier (free PDF)

If you have any lingering groups that serve the graphical environment (such as X.org), you can remove those as well. Just use caution with this, as you could wind up removing something crucial.

Reboot the server and you should now be presented with a text-based login.

And believe it or not, that’s all there is to removing GNOME from CentOS 7. Welcome back to your terminal-only CentOS 7 server installation.

Also read…