sometimes happens that some applications crash and make Gnome desktop unstable for example the upper bar vanishes. by restarting X ctrl+shift+backspace i can reset it. but is there a way just to re enable the bar or Gnome entirely?

  • 1
    Which version of GNOME are you using 2 or 3?
    – slm
    Sep 19, 2013 at 14:19

4 Answers 4


You should be able to restart Gnome with

 gnome-shell --replace

From the manual:

   GNOME Shell provides core user interface functions for the GNOME 3 desktop,
   like switching to windows and launching  applications.  GNOME  Shell  takes
   advantage  of  the  capabilities of modern graphics hardware and introduces
   innovative user interface concepts to provide  a  visually  attractive  and
   easy to use experience.

          Replace the running window manager
  • 1
    This works if you can still use a shell from the GUI. If you can't see my answer where I do it from another shell. Apr 15, 2020 at 18:33

You can press Alt-F2 (IIRC) to get a window where you can type a command. In addition to regular commands, GNOME Shell supports a couple of custom commands to control the behavior of the desktop environment. In this case, you want restart, which restarts the Shell, not the computer.

If it's crashed too much for that to work, use terdon's answer.


TL;DR, if you cannot do it from the GUI just login as the same user (text console, ssh, etc) and type:

eval "$(while read -d $'\0' line; do printf 'export %q\n' "$line"; done </proc/$(pgrep -fu$USER gnome-session-binary)/environ)"
gnome-shell --replace >.xsession-errors 2>&1 &

I do it often from a text console. You can switch to other consoles using CTRL+ALT+Fn where n is a free console number, usually starting from F3 as F1 is the login screen and F2 is the first session.

It obviously won't work with Wayland since gnome-shell restarts are just not supported on it.

Detailed answer:

The trick is to replicate the environment required by gnome-shell - I haven't verified exactly what is needed but at the very least you need DISPLAY and XAUTHORITY so gnome-shell can connect to the X server, and then a few additional ones are very likely required by gnome-shell and its extensions.

The process tree should look a bit like this:

      |            |-gdm-session-wor(6444)-+-gdm-x-session(6464)-+-Xorg(6466)-+-{InputThread}(6472)
      |            |                       |                     |            `-{radeon_cs:0}(6467)
      |            |                       |                     |-gnome-session-b(6475)-+-evolution-alarm(6712)-+-{dconf worker}(6789)
      |            |                       |                     `-{gmain}(6465)
      |            |                       |-{gdbus}(6446)
      |            |                       `-{gmain}(6445)

In this example gnome-session-binary (pid 6475) is the parent of all gnome session processes, so this is what I use to get the environment. If we used gnome-shell directly we'd see a lot more variables set by gnome-shell itself for its subprocesses.

I use pgrep to return the pid of that process for the current user only (there should always be only one pid even with multiple users logged in; if you have managed to log on twice something went terribly wrong).

Then I read that task's environ file from /proc/<PID>/ (null-separated list of environment variables), and prepend all lines with export. Those commands are then fed back to my shell through eval.

At this point I can run gnome-shell --replace like if I was doing it from the GUI session. If you plan on keeping that shell open you will likely want to redirect STDOUT and STDERR somewhere too; you can send it to /dev/null but I like to keep it around just in case (.xsession-errors is the legacy file X used to throw all GUI output to; on modern systems I believe systemd or journald capture all output and logs it instead).

  • This looks very promising. Have made a script for it, and for the first time in forever I'm actually waiting for GNOME to freeze lol. termbin.com/1bid
    – ibuprofen
    Feb 20, 2022 at 15:58

You can restart gnome using as root:

services gdm restart
  • Why was this downvoted? Does it not work correctly?
    – Setaa
    Jun 11, 2020 at 20:01
  • This working correctly
    – xnohat
    Sep 6, 2023 at 16:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .