Run X server on startup on CentOS

20,703

Solution 1

(I'll repeat the warning that you shouldn't be logging in as root, which you have been doing.)

This might happen if, for instance, you installed the system without the GUI and then installed it later. In this case, the system is not automatically configured to start the GUI.

If your system is somehow not configured to start the GUI automatically, you can fix this by changing the default target that systemd loads at boot.

systemctl set-default graphical.target

On the next boot, the GUI should start up. If you need to start it immediately, you can also do that.

systemctl start graphical.target

Solution 2

It should spring into life automatically if you are stating in runlevel 5.

You can find out the current runlevel with who -r or runlevel.

How you change the runlevel depends on which version of CentOS you are using. Prior to version 7, it was via the inittab.

If you are in runlevel 5 but don't have a X server running on your machine (you should a [x|k|g]dm graphical login or go direct to a sesion if you have configured auto login, then there's something wrong with your X configuration or the runlevel is broken. Check your logs.

sudo /usr/bin/X :0 &

Not a good idea to run your default session as root.

Share:
20,703
Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    How do you run X server on startup in CentOS? This is the command I use to manually start X server -

    sudo /usr/bin/X :0 &