Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

5 Answers 5

How to restart the display manager

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 restart:

sudo restart gdm

Or you can use the service command:

sudo service gdm restart

Init script hackers stuck on sysv will prefer invoke-rc.d:

sudo invoke-rc.d gdm restart

If it's really hung..

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

Which example should I use? Does it matter?

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, service and 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.

share|improve this answer
    
Note that as of 11.10 you should restart/kill lightdm rather than gdm. –  Hamish Downer Feb 20 '12 at 22:30
    
@HamishDowner As noted in the second sentence : ) –  djeikyb Feb 21 '12 at 1:04

sudo pkill X does the job for me

share|improve this answer
up vote 1 down vote accepted

I found a much easier way to restart the GUI.

In most cases you can just use: Alt+PrintScreen+K

share|improve this answer

Try invoke-rc.d gdm restart as root.

share|improve this answer
    
I haven't tested that command on Ubuntu, but it works on Debian Squeeze –  sakjur Feb 20 '12 at 18:51
    
While this command works, it's intended for people hacking on init scripts. The end-user variant, what your answer should recommend instead, is service. –  djeikyb Feb 20 '12 at 20:06
    
Voted up your reply. Those small differences between Debian and Ubuntu is the difference between power user and user ;) –  sakjur Feb 21 '12 at 11:44

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

share|improve this answer
    
On Ubuntu 11.10, shouldn't you run sudo service lightdm restart? –  Jakob Feb 20 '12 at 19:25
1  
Advocating a magic sysreq reboot is a terrible answer to this question, just short of "Pull the power plug". Recommending service is great though. –  djeikyb Feb 20 '12 at 20:16
1  
@djeikyb, the ALT+Printscreen is leagues better than pulling the plug because it safely sends SIGTERM and SIGKILL and unmounts filesystems. That's why I recommended CTRL+ALT+BACKSPACE first and followed up by saying I personally don't use the ALT+Printscreen. –  Huckle Feb 20 '12 at 20:27
    
@jakob, yes lightdm is now the default, but some people replace it with gdm or otherwise. –  Huckle Feb 20 '12 at 20:29
    
In this context I refer to this question, which is helpful to "expand the context". –  Jakob Feb 20 '12 at 21:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.