How to kill and to start the X server?

Solution 1:

One way to restart an instance of the X server is to run (from the commandline)

sudo service lightdm restart

For Ubuntu 15.04 and later:

sudo systemctl restart lightdm.service

and for Kubuntu 15.04 and later:

sudo systemctl stop sddm.service

Solution 2:

On 12.04, you can restart the server with the shortcut keys: Right Alt + Print Screen + K.

Solution 3:

In Ubuntu 14.04:

Press Ctrl+Alt+F1 and then run:

sudo service gdm stop

or

sudo service lightdm stop

… depending on your display manager.

NOTE: To recover use startx, alternatively replace the stop with start in either of the above commands.

Solution 4:

Kill : xkill -a. -a means it will kill all display instances. For more information run man xkill.

Run : xinit. Also startx but this command is to start an instance and not the server itself. For more information run man xint and man startx.

I don't believe it's possible to kill Xserver from GUI, and even if it were, it would not be the right way to do it.