127

Sometimes, my gnome-shell freezes. I can see (hear) background processes working (playing music), but I can't do anything in gnome. No Alt+F2+R.

I can switch to console using: Ctrl+Alt+F1, login as the same user and execute:

gnome-shell --replace

and return back Ctrl+F7, but then, I get a strange behavior. For example I cannot edit network connections. I cannot logout as well. What is the proper way to restart the gnome-shell?

  • Does gnome-shell freezes while using the search-function in gnome-shell overview, or on what particular occasion, if you can tell? – v2r Apr 26 '14 at 1:09
  • 1
    No, it freezes after login (mostly), usually after undocking. – jk_ Apr 27 '14 at 18:10
  • 2
    So far, I didn't found a working solution. In the end, I end up with this workaround. – jk_ Apr 29 '14 at 12:41
  • If you use any shell-extensions from: extensions.gnome.org deactivate all of them and reboot, to see if one of them caused the trouble. I use an older version of gnome-shell and had plenty of issues due to that exact cause! (Maybe it is just as simple as that?!) – v2r Apr 30 '14 at 15:20
  • 1
    I tried to deactivate all of them, still having the problem :( – jk_ May 5 '14 at 8:24
175

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.

  • 3
    +1 for the SIGHUP tip, however, wouldn’t the correct command then be killall -1 gnome-shell? At least according to man 7 signal, the value for SIGHUP is 1. Value 3 corresponds to SIGQUIT. I have sent value 1 to the Gnome Shell and it was cleanly restarted as expected. – Chriki Apr 29 '15 at 8:24
  • @Chriki yeah, it was sigquit, through most signals would make gnome-shell process end. – Braiam Apr 29 '15 at 13:31
  • 1
    I tried this on Fedora 25 and killall -3 gnome-shell resulted in killing all applications for me. – comfreak May 26 '17 at 16:08
  • 6
    I wish we could also use a terminal command having exactly the same effect as Alt+F2 and r, i.e. without blanking the whole screen... – Sadi Jun 11 '17 at 14:04
  • I run into the issue of gnome crashing a lot on my ubuntu vm, I was having to restart the VM every time it happened. Being able to ssh in and use this command solves that issue, thanks a million. – Nathan F. Apr 14 '18 at 21:38
32
  • 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.
  • I created a shell function that sets the DBUS_SESSION_BUS_ADDRESS from the gnome-shell process environment (so you can logout otheruser1 otheruser2) askubuntu.com/a/874504/17941 – sehe Jan 21 '17 at 13:25
  • 3
    Got the error Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Shell was not provided by any .service files without sudo and Failed to open connection to "session" message bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11 with sudo. – Seanny123 Nov 9 '17 at 16:24
7

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!

  • 6
    be careful, I did it on the same TTY and this kill my current session.. – RousseauAlexandre Oct 24 '18 at 12:51
  • this completely fucked up the current session: it started to blink and then went to nirvana.. had to reboot. – Nik O'Lai Oct 11 at 18:11
7

Here is a different workaround:

  1. Log in a local terminal by pressing CTRL+ALT+F1.
  2. Run the command:

    sudo kill -HUP $(pidof gnome-shell)
    
  3. Return to the graphical interface by pressing CTRL+ALT+F7.

PS: I'm using lightdm instead of gdm3.

  • 1
    Simple, and works like a charm! (At least for me) – Katai May 10 '18 at 12:51
5

Since you are not satisfied with gnome-shell --replace, you might want to try restarting the display manager itself.

sudo service lightdm restart

I think that will kill other processes you are running. Also refer http://worldofgnome.org/how-to-restart-gnome-shell-when-freezes-if-ever/

If you are seriously into something that make you freeze everytime, enable the SysRq as mentioned in https://www.kernel.org/doc/Documentation/admin-guide/sysrq.rst, and then give <alt><sysrq/print_screen_key><k> to kill whatever its there on the screen.

  • 3
    Restarting lighdm works, but I want to avoid it, because I have to reopen everything from a scratch. Especially if I know it is problem of a Gnome-shell and restarting it almost works. – jk_ Apr 25 '14 at 17:29
  • I am unaware of other methods to restrat just the gnome shell. Did you try whether DISPLAY=:7 gnome-shell --replace works ? – Jay Aurabind Apr 25 '14 at 17:43
  • 1
    No, it does not, I use display, when w shows display different than :0. If I use a wrong display I get an error. – jk_ Apr 26 '14 at 9:07
  • Sorry, I'm out of options. You should probably ask in the gnome user/developer mailing list. First figure out why you have abnormalities with alt-f2-r or gnome-shell --replace when it is the gnome's recommended way. – Jay Aurabind Apr 26 '14 at 9:45
  • So am I. I did even followed this link setting up more ENV variables, but I still cannot edit network connections when restarting gnome-shell from a different terminal. In the end, I end up with this trick – jk_ Apr 29 '14 at 12:38
2

I do sometimes have the same problem as you describe, and my solution is:

Ctrl + Alt + F1, login as same user and execute:

sudo pkill -9 ^gnome-shell

And return back with Ctrl + Alt + F7

If this is the proper way, I don't know. For me it works everytime.

  • 3
    This will kill all users instances of gnome-shell which may not be something you want to do in a multi-user scenario. Normally you only have to kill your own (pkill -HUP gnome-shell) – Steeve McCauley Aug 4 '14 at 13:37
  • great it works for me...! you save my day. appreciated. – NomanJaved May 18 '18 at 19:13
2

Restart X

  • First find which display manager your Ubuntu is using with following command:

    cat /etc/X11/default-display-manager
    

    in my case it's /usr/sbin/gdm3

    From Inside X or OUTSIDE X

  • For Method 1 to 4, find out which display you're using by using the w command.

    w
    

    the answer may be for example tty3, (therefor my (ack's) "return to my display" key is Ctrl+Alt+F3

Methods

  1. Ctrl+Alt+F1 to exit, and Ctrl+Alt+F3 to bring one back
  2. sudo /etc/init.d/gdm3 restart
  3. systemctl restart gdm.service
  4. sudo service gdm3 restart
  5. dbus-send --type=method_call --print-reply --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'global.reexec_self()'
  6. An easy way is just pressing Alt + F2, and type r then press Enter. This will work so long the shell isn't unusable.
  • Method 5 is lifted verbatim from korc's answer and 6 from Braiam's answer. Plagiarism isn't against the rules here, but it's definitely not cool. All you really need to do is indicate that the work is not your own by putting it in quotes, and give attribution by including a link to the source post and a link to the author's profile page. For more details, see this blog post: Attribution Required – wjandrea Sep 1 at 18:31
1
  1. Press Ctrl+Alt+F2 to switch to a terminal window. Sometimes, this is not possible.

  2. Press Alt+SysRq+R to get the keyboard.

  3. If pressing Ctrl+Alt+F2 before failed, try it again now.

  4. Press Alt+SysRq+E to terminate all processes.

  5. Press Alt+SysRq+I to kill all processes.

  6. Press Alt+SysRq+S to sync your disks.

  7. Wait for OK or Done message. If you don't see a message, look at your HDD light to see if Sync made a difference.

  8. Press Alt+SysRq+U to unmount all disk drives.

  9. Wait for OK or Done message. If you don't see a message in 15-30 seconds, assume disks are unmounted (or that an unmount is not possible) and proceed.

  10. Press Alt+SysRq+B to reboot.

0

kill -15 gnome-shell does not work for me but kill -9 does. I think it is because kill -9 triggers a segfault which triggers gnome-shell to restart itself, while kill -15 does not.

  • 2
    kill -9 doesn't trigger a segfault. It sends SIGKILL, an uncatchable signal for which the only action is to quit immediately. It should only be used when the application doesn't respond to SIGTERM, which is 15. – muru Jan 17 '16 at 21:28
  • pkill -11 gnome-shell would trigger a segfault, since that's literally what signal 11 does. BTW, kill needs a process ID, NOT a process name. Did you mean pkill or killall? – TSJNachos117 Oct 10 '17 at 15:42

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.