Skip to main content

Booting CentOS into Graphical or Command Line Mode by default

np_close_142259_000000-3


Ok, now that I’ve installed CentOS, I decided to install X Windows. And like Rip Van Winkle, I learnt that a lot has changed in 20 years :)

A windowing environment was easy to install …

sudo yum groupinstall "Gnome Desktop"

and the trusty old startx & gave me a Windowing Environment (which I have yet to explore)

However, switching permanantly to graphics mode (or vice versa) wasn’t so easy. I wanted to set my command line as the default startup environment and so I went to look for the default runlevel. I coudn’t find it. That’s because they don’t exist anymore. No inittab of old, nothing.

The init scripts of old have now been replaced (for quite a while) by systemd. And while it’s old (most Linux distributions have adopted it for nearly 3-5 years now) it’s still new to me :)1

So, systemd targets something called targets2 instead of runlevels. (Haha, see what I did there? :P) Targets to my mind involve a collection of settings in a file all relating to … something … a service.

You could group all of your network stuff in a network target, or like I needed it all your runlevel settings in a command line target or a graphical target.

Aha!

So a quick search led me to the systemctl get-default command which gives my my default target graphical.target

Another search gave me the multi-user target to use if I wanted a multiuser command line environment.

So to switch all I had to do was, systemctl set-default multi-user.target

Et voila!

If I ever wanted my graphical environment back as a default setting, systemctl set-default graphical.target

And Bob, as they say, is my uncle.


  1. and apparently still quite a source of controversy and debate 

  2. which I need to learn lots more about