This article explains how to restart GNOME Shell from the command line, without closing any applications (X11 only).
GNOME Shell can be restarted without closing all applications only on X11 (used by default on Ubuntu for example); under Wayland (which is what Fedora uses by default for example), GNOME Shell is the display server, and if the display server goes down, all running applications go down as well, so this doesn’t work. If you use this under Wayland, the session is restarted, closing all running applications.
I assume you already know that while GNOME Shell is running (it hasn’t crashed), you can restart it and keep all running applications by pressing
Alt + F2, then type
r and press the
But what if you want to restart GNOME Shell from the command line without closing all applications? This can be useful in a script, or attach the command to a keyboard shortcut so you can restart GNOME Shell in case it freezes / becomes unresponsive, etc.
busctl --user call org.gnome.Shell /org/gnome/Shell org.gnome.Shell Eval s 'Meta.restart("Restarting…")'
This is a single command – triple click the line to select it.
Since this is what GNOME Shell does when running
Alt + F2 and typing
r, this is the best way of restarting GNOME Shell from the command line. h/t Lucas Werkmeister for this command.
In case this doesn’t work for some reason, another command that should restart GNOME Shell is:
killall -HUP gnome-shell
This keeps some running applications, but others are closed. Also, if you keep running this, GNOME Shell might detect that something went wrong and disable all your extensions, logging you out in the process. So this command is not perfect, that’s why I don’t recommend using it unless you really have to.
So what does this HUP signal do? This is sent to a program to request it to restart and re-read its configuration.
Another way of restarting GNOME Shell that only works with GNOME Shell 3.28 and older, is to run
gnome-shell --replace. This no longer works properly with GNOME Shell 3.30 and newer – if you try in such a case, it will crash GNOME Shell, forcing you to logout.