Restarting GNOME Shell From the CLI

Earlier this evening, while attempting to use remote desktop to fix a system, I had the shell brick on me — no external mouse (USB), no touchpad and no window controls.

However, with a few booted VMs open, 200 or so browser tabs and several in-use terminals in use, not being able to switch between apps, or close them reliably might have caused me a problem, if, that is, the way we used to fix this kind of thing in the 1980′s didn’t still work in 2013.

So, Control-Alt-Fx’ing and logging into a terminal it is — and making sure my traditional ps axuw | grep gnome-shell returned nothing gnome-shell was running, I did:

export DISPLAY="0:0"

Which, obviously would be different if you have more than one X session running, or are working from a tunnel — but for end-users with a single desktop display, 0:0 will almost certainly work.

Then, it was a simple case of restarting the shell:

gnome-shell --replace

and switching back to my GUI with Control-Alt-F7 — to find a restarted shell complete with window controls — problem solved :)