On Ubuntu, you can type Alt-F2 to get the "Run Command" prompt, you can just type r there, and the desktop GUI will be restarted, without the need to log off and log on again ...

Here are a bit more details on this procedure for Ubuntu Gnome3: https://linuxconfig.org/how-to-restart-gui-on-ubuntu-20-04-focal-fossa

However, I cannot do the same on Raspbian Stretch:

Alt-F2 R

Alt-F2 R fail

... since Alt-F2 + r fails with: Failed to execute child process "r" (No such file or directory).

The above link mentions that in Ubuntu Gnome3, Alt-F2 + r is equivalent to the commands:

  • gnome-shell --replace (sudo not required); or
  • sudo systemctl restart systemd-logind (sudo required).

I've tried sudo systemctl restart systemd-logind on Raspbian Stretch - but it looks like it does not restart the desktop GUI.

I also found this post: https://unix.stackexchange.com/questions/518001/what-commands-are-run-by-altf2-and-r - and for cinnamon desktop, apparently the commands are:

  • pkill -HUP -f "cinnamon --replace"
  • dbus-send --type=method_call --print-reply --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'global.reexec_self()' (this is also for Gnome desktop)
  • dbus-send --type=method_call --print-reply --dest=org.Cinnamon /org/Cinnamon org.Cinnamon.Eval string:'global.reexec_self()'

So - is there a similar "restart GUI" command that I can use in Raspbian without sudo? (I'm interested in the command line - but ultimately, I would want to put it as a shortcut in the Raspberry menu...)

  • 1
    What exactly are you trying to achieve. There are lots of ways, but there seems little point.
    – Milliways
    Sep 1, 2020 at 10:06
  • Thanks @Milliways - see below, just answered the question myself.
    – sdbbs
    Sep 1, 2020 at 10:13

1 Answer 1


Ok, I think I found it - first I was wondering what is the desktop environment in Raspbian Stretch, and I found this post https://www.raspberrypi.org/blog/introducing-pixel/ - and I thought it was called PIXEL.

But then, via https://itsfoss.com/find-desktop-environment/ I found out about screenfetch, so:

pi@raspberry:~ $ sudo apt install screenfetch
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Unpacking screenfetch (3.7.0-1) ...
Setting up screenfetch (3.7.0-1) ...
Processing triggers for man-db ( ...

pi@raspberry:~ $ screenfetch 
    .',;:cc;,'.    .,;::c:,,.    pi@pi-boxcalmeas-05
   ,ooolcloooo:  'oooooccloo:    OS: Raspbian 9.13 stretch
   .looooc;;:ol  :oc;;:ooooo'    Kernel: armv7l Linux 4.19.66-v7+
     ;oooooo:      ,ooooooc.     Uptime: 1d 31m
       .,:;'.       .;:;'.       Packages: 1320
       .... ..'''''. ....        Shell: 3557
     .''.   ..'''''.  ..''.      Resolution: 1024x768
     ..  .....    .....  ..      DE: LXDE
    .  .'''''''  .''''''.  .     WM: OpenBox
  .'' .''''''''  .'''''''. ''.   CPU: ARMv7 rev 4 (v7l) @ 1.4GHz
  '''  '''''''    .''''''  '''   GPU: Gallium 0.4 on llvmpipe (LLVM 3.9, 128 bits)
  .'    ........... ...    .'.   RAM: 153MiB / 926MiB
    ....    ''''''''.   .''.    
    '''''.  ''''''''. .'''''    
     '''''.  .'''''. .'''''.    
      ..''.     .    .''..      

Ok, so it's an LXDE desktop - and so I found this post: https://www.makeuseof.com/tag/refresh-linux-desktop-without-rebooting/ which told me I need to use:

pi@raspberry:~ $ lxpanelctl restart && openbox --restart

... and this indeed seems to reload/restart the desktop...

Adding menu items is discussed here: http://cagewebdev.com/raspberry-pi-adding-start-menu-items/ - and that page mentions instead:

lxpanelctl restart

... which to me seems to only "refresh" the top menu bar?

The Raspberry Pi logo is here:

pi@raspberry:~ $ ls -la /usr/share/icons/PiX/48x48/places/distributor-logo.png 
lrwxrwxrwx 1 root root 14 Sep 26  2018 /usr/share/icons/PiX/48x48/places/distributor-logo.png -> start-here.png
pi@raspberry:~ $ ls -la /usr/share/icons/PiX/48x48/places/start-here.png lrwxrwxrwx 1 root root 12 Sep 26  2018 /usr/share/icons/PiX/48x48/places/start-here.png -> rpi-logo.png
pi@raspberry:~ $ ls -la /usr/share/icons/PiX/48x48/places/rpi-logo.png 
-rw-r--r-- 1 root root 3709 Sep 26  2018 /usr/share/icons/PiX/48x48/places/rpi-logo.png

I create a .desktop file via: sudo nano /usr/share/applications/RestartRPiDesktop.desktop, with these contents:

[Desktop Entry]
Comment=Restart the Raspbian Desktop GUI
Exec=/bin/bash -c 'lxpanelctl restart && openbox --restart'

Then I did lxpanelctl restart - and there is a new item under Graphics in the menu:

desktop menu icon

... and it seems to restart/refresh the desktop GUI fine - so all is good ...

  • 2
    I would remove everything until the point where you describe the .desktop file. There's no point in describing how you discovered RPi OS is using LXDE/openbox. Sep 1, 2020 at 14:05
  • 1
    Please mark the answer as the accepted one with a click on the tick on its left side. That prevents your Question from being shown as a unsolved Post to the community and saves them/us a lot of work.
    – Ingo
    Sep 5, 2020 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.