This article describes how to restart GNOME Shell (X11 only) from the command line without closing any applications.
GNOME Shell can be restarted without closing all applications that are only on X11 (for example, it is used on Ubuntu by default); in Wayland (for example, the way Fedora is used by default), GNOME Shell is the display server, if When the display server is shut down, all running applications will be shut down, so this doesn’t work. If you use this feature in Wayland, the session will restart and close all running applications.
I assume you already know that when GNOME Shell is running (it did not crash), you can restart it and keep all running applications by pressing
Alt + F2And enter
r then press
But what if you want to restart GNOME Shell from the command line without closing all applications? This is useful in scripts, or to attach commands to keyboard shortcuts so that you can restart GNOME Shell if it freezes/is unresponsive, etc.
Alt + F2 Then type
r As follows (so this command will restart GNOME Shell without closing any running applications):
busctl --user call org.gnome.Shell /org/gnome/Shell org.gnome.Shell Eval s 'Meta.restart("Restarting…")'
This is a command-double-click the row to select it.
Because this is what GNOME Shell does at runtime
Alt + F2 Then type
r, This is the best way to restart GNOME Shell from the command line. H T Lucas Werkmeister For this command.
If for some reason this command does not work, another command that should restart GNOME Shell is:
killall -HUP gnome-shell
This keeps some running applications, but other applications are closed. In addition, if you continue to run it, GNOME Shell may detect what went wrong and disable all extensions, which will cause you to exit the process. Therefore, the command is not perfect, which is why I don’t recommend you use it unless you really need it.
So what does this HUP signal do? This is sent to the program, asking it to restart and re-read its configuration.
Another way to restart only GNOME Shell 3.28 and earlier versions of GNOME Shell is to run
gnome-shell --replace. This no longer works properly on GNOME Shell 3.30 and later-if you try in this situation, it will crash GNOME Shell, forcing you to log out.