In today’s Linux guide, I’ll show you how to restart Ubuntu X Server from the command line or terminal. In some cases session might freezes and you’re stuck because don’t know what to do to resolved it.
If you’re wondering, X Server provides you with graphical desktop interface in the Linux environment. X server can freezes because of bugs from the graphic drivers.
For you to able to restart the X Server without restarting your Ubuntu machine, from the terminal run one of these commands:
Ubuntu 11.04 or newer using Gnome
sudo service gdm restart
Ubuntu 11.10 or newer using LightDM
sudo service lightdm restart
Ubuntu 11.10 or newer using KDE
sudo restart kdm
Ubuntu 15.04 or newer
sudo systemctl restart display-manager
Or, if you’re unsure what Ubuntu version currently running you can also use this command from the terminal, this code should work on all Ubuntu version:
sudo pkill X