How can I end the GUI from a different TTY, then start up a new one.
This is for the occasional freeze of the GUI, or inaccessibility. When all I can do is switch to another TTY (using Ctrl+Alt+F5 for TTY5) and start over, or reboot.
If X is hung, you should be able rejigger it by restarting the display manager. In 11.10, it's lightdm, recent past versions use gdm. Change the following examples as appropriate for your version. You can restart it a few different ways. I prefer the simplicity of the
sudo restart gdm
Or you can use the
sudo service gdm restart
Init script hackers stuck on sysv will prefer
sudo invoke-rc.d gdm restart
If restarting the display manager doesn't work, pull out a hammer and kill it dead with one or both of these commands:
sudo pkill -9 X sudo pkill -9 gdm
Use the first one.
restart is a link to
initctl, which is Upstart, which is Ubuntu's init manager that they are trying to convert everything over to.
The other two commands,
invoke-rc.d are there only to control the old-style SysV init scripts. SysV exists in modern Ubuntu only for backwards compatibility. Don't rely on it. But if you must..
service is for end-users. It returns a simple exit code. If you're a normal user needing to control a SysV style init script, use this tool.
invoke-rc.d is for init script hackers. It returns a bunch of varied and useful exit codes. There's no reason a normal user should use this tool. There isn't any harm for normal users, it's just more complicated.
sudo pkill X does the job for me
I found a much easier way to restart the GUI.
In most cases you can just use: Alt+PrintScreen+K
invoke-rc.d gdm restart as root.
If CTRL+ALT+BACKSPACE doesn't end the current X server and plop you back in lightdm or gdm then there is an alternate sequence (which I've personally never tried) that goes like this: ALT+PrintScreen+R-E-I-S-U-B, however this will actually reboot the machine. My preferred method is to just CTRL+ALT+F1 to get to a terminal and then
sudo service gdm restart and that will also bring you back to the login screen