If you install a CentOS server, but accidently also installed Desktop Environment such as GDM, GNOME or X Window, you can easily remove the GUI packages and return back to Command Line (CLI).
There are two ways to do that. You can simply disable GUI or completely uninstall it. I will provide steps to do both.
Temporary Disable GUI (GDM)
Open inittab with nano
nano /etc/inittabchange
id:5:initdefault:to
id:3:initdefault:
Remove GUI
If you want to remove all GUI packages completely, please use disable GUI steps first otherwise once Gnome, GDM, X Windows removed CentOS will still try to load X Window.
To remove GUI packages:
yum groupremove "GNOME Desktop Environment" -y yum groupremove "X Window System" -y
If you want to temporarily stop GDM (GUI), you can run this command:
init 3
If you want back to start GDM:
init 5