You installed CentOS with the GUI and you want to remove it later? Instead of removing it, you can just switch the system from GUI to the terminal. For this, we will use systemd targets.
Below are the systemd targets used in RedHat/CentOS 7+:
Runlevel | Target Units | Description |
0 | runlevel0.target, poweroff.target | Shut down and power off the system. |
1 | runlevel1.target, rescue.target | Set up a rescue shell. |
2 | runlevel2.target, multi-user.target | Set up a non-graphical multi-user system. |
3 | runlevel3.target, multi-user.target | Set up a non-graphical multi-user system. |
4 | runlevel4.target, multi-user.target | Set up a non-graphical multi-user system. |
5 | runlevel5.target, graphical.target | Set up a graphical multi-user system. |
6 | runlevel6.target, reboot.target | Shut down and reboot the system. |
To switch from GUI to terminal/non-graphical user interface, use:
systemctl set-default multi-user.target
reboot
To switch from terminal/non-graphical user interface to GUI, use:
systemctl set-default graphical.target
reboot
Resources:
SYSTEMD TARGETS