Restore/Reload/Recover Crashed Gnome 3 Shell From tty1

Posted by on Jan 5, 2012 in Linux18 comments

I switched over to Linux Mint – a very nice Ubuntu derivative – a few releases back, and have just updated to “Lisa”, aka Linux Mint 12. The latest release uses Gnome 3, which is vastly different from Gnome 2 in pretty much every way. As much as I loved Gnome 2, I have to say, I don’t hate Gnome 3. In fact, I rather like it, despite its quirks, and my unfamiliarity concerning customising and tweaking. Besides, learning is half the fun of a new system.

One annoyance I have found to be somewhat of a show-stopper is that the Shell seems to crash on a fairly regular basis. I’m still trying to work out what is causing the crash – it could be one of the few extensions I have installed and modified to get the system looking and feeling the way I want, or some other bug related to the Shell, ATI Graphics driver, Xserver…

Unfortunately, when the shell crashes, the application windows remain, but all the panels and shell related stuff vanishes. It’s also not possible to use Alt-F2 to bring up the Run command widget, from which it’s possible to simply run “r” to reload the shell. Instead, I have had to find a couple of alternative methods to reload the shell. One is particularly drastic, and involves killing the whole Gnome session – not good if you have work to save etc. The other just replaces the shell.

The “Nice” Method

This method will replace the Gnome shell using tty1. As a result, all output from the gnome-shell command will be output to standard output on tty1, although this can be redirected to /dev/null or somewhere else if desired. To use this method, press Ctrl-Alt-F1 to change the display to tty1, and login if necessary. Then run:

DISPLAY=:0 gnome-shell --replace

This effectively tells the system to redirect the gnome-shell –replace command to tty7, i.e. the Xserver.

Once done, press Ctrl-Alt-F7 to return to Gnome.

The more aggressive method

This method will completely restart the Gnome session, killing any open applications in the process. This really is a last resort, and rather horrible method. Once again, press Ctrl-Alt-F1 to change the display to tty1. Once there, run:

ps aux | grep 'gnome-session'

You should see a few lines of output. What you’re looking for is (most likely the first line) the line similar to this:

username 4321 0.0 0.1 00000 00000 ? Ssl 09:48 0:00 /usr/bin/gnome-session --session=gnome

Where “username” is your username. Look specifically for “/usr/bin/gnome-session –session=gnome”. The number in the second column (after the username) is the value we’re after – in this case “4321”. This is the PID (Process ID) for gnome-session, and the value required to kill the session:

sudo kill -9 4321

This should kill the crashed Gnome Shell session, and start a new one. The display should also be returned to tty7, and the Login screen (if not, press Ctrl-Alt-F7).

If anyone else has any alternative, or better methods, please feel free to comment below.

Tags: , ,