How can I restart GNOME Shell, after it freezes or becomes unresponsive?

Solution 1:

The easier way is just pressing Alt + F2, type r then Enter. This will work so long the shell is usable.

You can also send SIGQUIT to the gnome-shell process which will terminate only the shell:

killall -3 gnome-shell

Other methods use more destructive means, which close all the applications, this shouldn't.

Solution 2:

  • If you want to ask "nicely" to gnome-shell to restart itsself, then you can call it's internal restart function over dbus with following command (assuming you have DBUS_SESSION_BUS_ADDRESS env var set to the correct value and run as same user):

    dbus-send --type=method_call --print-reply --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'global.reexec_self()'
    
  • If you want to run a new instance, gnome-shell --replace should do fine. On console you need to define necessary environment variables like DISPLAY, DBUS* and so on. Refer to /proc/$gnome_shell_pid/environ

  • If you want to restart existing one, then killall -HUP gnome-shell will do it. If you do that too often though, gnome-shell might disable all extensions, forcefully log you off or otherwise behave in non-userfriendly manner.

Solution 3:

If you have installed ubuntu gnome, which you should have, you might be using the gnome display manager. In that case you should change to another TTY, like Ctrl + Alt + F4 and then

sudo service gdm restart

I also wrote an article about such situation recently:

Help, my Linux Desktop hangs!

Best Luck!