For disabling the GUI login mode, do the following steps

Open the terminal and do the following commands as root user or sudo user.

For CentOS 6 or RHEL 6

Edit /etc/inittab, enter:

# nano /etc/inittab

Find:

id:5:initdefault:

Replace with:

id:3:initdefault:

Save and close the file.

For stopping the currently running GUI session:

# init 3

To get back into the GUI mode temporarily, type the following in the terminal.

# init 5

For RHEL 7 or CentOS 7

To see default

systemctl get-target 

To switch GUI off (equivalent to init 3 in the previous versions)

systemctl set-target multi-user.target 

To Enable GUI (equivalent to init 5 in the previous versions)

systemctl set-target graphical.target

For RHEL 8 or CentOS 8

To see default

systemctl get-target 

To switch GUI off (equivalent to init 3 in the previous versions)

systemctl set-target multi-user.target 

To Enable GUI (equivalent to init 5 in the previous versions)

systemctl set-target graphical.target