Run X server on startup on CentOS

Josh Unger asked:

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 &

My answer:


(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

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.