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
can we do this without changing inittab file editing
Yea… it is possible. Removing the corresponding module is another way. But the problem with removal is , if we need it after sometime, then we need to install it again.
Inittab editing is just disabling the UI only, not removing.
If it is required, we can load it also.
The new way of doing it on system systesm (rhel7,…) is `systemctl set-default multi-user.target`
Doesn’t work anymore, now it is “systemctl get-target” to see default and “systemctl set-target multi-user.target” to switch GUI off (old init 3) or “systemctl set-target graphical.target” (old inti 5).
Thanks for notifying me. This article was posted in 2013. I have made the changes and included the commands for CentOS 7/RHEL 7 also.
Hi! The commans for RHEL/CentOS 7 and 8 are not “set-target” and “get-target”, they are “set-default” and “get-default” instead.
On RHEL 7 type – [systemctl set-default multi-user.target] without brackets for non GUI RHEL 7
For Centos 7 & it’s “systemctl get-default” To see the default parameters.