CentOS - How to Boot into a Graphical Environment: Auto-Start to GUI - StartX How to configure your CentOS machine to auto-start to the installed GUI (GNOME, KDE or others) right after the boot-up sequence

Protect CentOS from unwanted SSH failed login attempts with Fail2Ban

Right after you install CentOS, you'll be able to access your system with the standard Linux login screen on a command-line prompt. If you want to access to a GUI, you need to do the following:

  • Be sure to have it installed.
  • Log-in, then type the following command: startx

In case you don't have a Graphical Environment installed, you can easily fix that by installing GNOME with the following shell commands:

It's worth noting that manually issuing the  startx  command will launch the GUI just for that specific session: in other words, it's a one-time fix and won't change the log in process for future logins.

To set up your system so that the GUI will be launched upon each login automatically, you need to do the following:

CentOS 6.x and earlier

  • Open the /etc/inittab  file.
  • Change the runlevel  option from 1 (or 3) to 5.

The /etc/inittab file tells init which runlevel to start the system at and describes the processes to be run at each runlevel. An entry in the inittab file has the following format:

Here's a list of all the available runlevels values:

You can alter the etc/inittab file with the text-editor you like: for example, you can do

or

 

CentOS 7.x and later

With the introduction of systemd, the file /etc/inittab is no longer used to set the default run level: the new /etc/inittab file became nothing more than a readme containing a short (and useful) guide to the new target-based system:

That pretty much summarizes what we have to do to enable the GUI on boot.

Open a shell command-prompt and type the following:

This sets the default runlevel to 5, which is multiuser with auto-loading the Graphics Environment on boot / startup sequence.

You can try these new settings with a reboot, which should prompt you with something similar to the following screenshot (if you're using GNOME):

CentOS - How to Boot into a Graphical Environment: Auto-Start to GUI - StartX

That's about it: happy GUI!

 

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.