I had a device running Ubuntu 12.04 LTS have its screen freeze. Generally I have simply jumped onto an available tty, i.e. Ctrl-Alt-F1 and executed the command /etc/init.d/lightdm restart or service lightdm restart. This however kills everything I have open. How do I avoid this?

  • 1
    You can't achieve this. It is lightdm which displays/manages windows in x system. – Apple II Mar 23 '13 at 1:46
  • This will also kill whatever you have open, but once upon a time ctrl-alt-backspace would restart X. That's easier than switching to a TTY, logging in, and asking X to restart itself. I'm not sure if it still works though. – user162316 Mar 23 '13 at 3:46
  • @Douglas B. Staple - It doesn't work with Ubuntu 12.04 LTS. Not sure whether it still works with other distributions or whether this is specific to Unity. – PeanutsMonkey Mar 23 '13 at 7:11
  • There may be some way to replace the window manager while running. (It's possible with the GNOME-Shell at least, or with the i3 window manager so there could be some way). – FSMaxB Mar 24 '13 at 8:51
  • @FSMaxB - Could you please elaborate on how this can be achieved using the Gnome-Shell or i3 Window Manager? – PeanutsMonkey Mar 26 '13 at 17:59

DISCLAIMER: According to Brenden's comment, this might be outdated and not work anymore with newer versions of Ubuntu. Also please be prepared that you might lose your open windows.

Now I got it for Unity (I just replaced my GNOME shell with unity without logging out or closing windows):

  1. Go to tty1 [Ctrl]+[Alt]+[F1]
  2. Type in DISPLAY=:0 so that programs know on what port to find the X-Server
  3. export DISPLAY
  4. unity --replace or gnome-shell --replace (you can also replace GNOME-Shell by unity or Unity by the GNOME-Shell)

This only works if not the X-Server or GNOME is frozen but only Unity or the GNOME-Shell.

How it works: The communication between programs and the X-Server for displaying their UI is working over a network socket. This normally is at "localhost:0" short ":0". By setting the DISPLAY variable, the programs know where to find the X-Server to communicate with it, so programs are displayed on the X-Server on tty7 even if the program is running on tty1.

The content of windows is managed by the X-Server whereas the position and borders of the windows is managed by the window manager integrated in unity or the GNOM-shell so there is a way to replace only them without restarting the applications on the X-Server.

PS: I'm just describing what I understand it to be, so please edit and correct me if I'm wrong in some points.

EDIT: For the GNOME-Shell, there is another way to restart it. After changing to tty simply type in pkill -HUP gnome-shell, I don't know if there's something similar for Unity.

  • That worked like a miracle. In fact it saved me today. Thanks so much. I would be so grateful if you could elaborate what each of the steps do bar step 1. I don't quite understand what is happening under the hood. – PeanutsMonkey Apr 1 '13 at 4:56
  • Thanks for answer! Note unity --help says: "--replace Run unity /!\ This is for compatibility with other desktop interfaces and acts the same as running unity without --replace" – Tom Jul 13 '15 at 19:59
  • Also I found I had to run unity via sudo to save my windows. – Tom Jul 13 '15 at 20:00
  • 2
    --replace is deprecated and does nothing and this solution will restart your session meaning you lose all of your windows :( – Brenden Aug 5 '15 at 15:23
  • Still works in 2018 – user000001 Apr 29 '18 at 14:51

If your screen is frozen, but mouse is still moving (however no result on left-click) - try

  1. close suspicious (in terms of locking too much memory) apps;

You can use keyboard alt-tab to select and alt-f4 to close.

  1. right-click anywhere.

Dunno why it happens and why right-click works, but at least it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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