I have a CentOS 6.2 OS which boots into GUI. How, upon startup, can I not boot into the GUI and instead, boot into the CLI? I want to do this at computer startup time.
4 Answers
When you are at the GRUB menu where you select which OS to boot (if this menu don’t appear, press ESC while you get the “Booting CentOS in X seconds”), press e to edit your boot commands. You should see a screen like this: (parameters may vary)
Look for the line that begins with kernel
. Choose it and then press e again. You will be at a simple editor, add 3
to the end of this line. This means booting in runlevel 3, which is text-mode only.
To make this stick: edit /etc/inittab
and look for a line that begin with id:5
. Replace the 5
in that line by 3
. You can find a brief description of runlevels here, but shortly:
- Runlevel 0 and 6: halt and reboot the machine, respectively.
- Runlevel 1: No services running, only root can login.
- Runlevel 2: Users can login but no networking.
- Runlevel 3: Networking and text-mode.
- Runlevel 4: unused.
- Runlevel 5: GUI.
-
3After making the kernel edit for the runlevel boot mode, (and pushing
b
for "boot"), is it still supposed to load the splash screen?– bgmCoderMay 19, 2012 at 21:10 -
1@BGM I think so, but it should drop you to the login prompt after it finishes.– RenanMay 19, 2012 at 21:11
-
-
Anyway, Renan has the answer. I also found it here: linuxquestions.org/questions/linux-server-73/…– bgmCoderMay 19, 2012 at 21:25
-
3For CentOS 7, type this into the Terminal: 'systemctl set-default multi-user.target' and to change it back, 'systemctl set-default graphical.target'– turiyagAug 24, 2015 at 18:43
- Apart from what Renan mentioned, you can switch to another runlevel by simply executing
sudo init [level-number]
-- this is temporary, when you reboot, you get to your default, configured in/etc/inittab
. - If you don't want to see splash screen, you need to replace kernel param
rhgb
withtext
in boot menu. To make it permanent, edit/boot/grub/grub.conf
.
In Centos 8, you have to use systemctl set-default TARGET.target
command and replace TARGET
with either multi-user
for runlevel of 3, i.e. Terminal, or graphical
for runlevel of 5.
So this is the command to use in Centos 8 to switch to Terminal when the system gets restarted:
systemctl set-default multi-user.target
Once in Terminal, you can start the GUI again if you need to by using:
systemctl isolate graphical
Here is how /inittab/etc looks on Centos - run:
systemctl set-default multi-user.target
and reboot to get to the CLI.
# inittab is no longer used.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target