Ubuntu 17.10 Tip: Graphical Apps Doesn’t Launch via Root, Sudo, Gksu

Last updated: October 11, 2017

Ubuntu 17.10 uses Wayland in the default session and Xorg for optional. However, many graphical applications need to run as root so far does not launch in Wayland.

You’ll get following similar errors while running graphical applications via root:

  1. For some applications, e.g., Synaptic Package Manager, Grub Customizer, Gparted, and Ubuntu Tweak, they does not launch in Wayland.

    Or you may get following error when trying to launch them via gksu command:

    Failed to run *** as user root. Unable to copy the user’s Xauthorization file.

  2. Starting graphical application via sudo in terminal window will get error:

    No protocol specified. Gtk-WARNING **: Cannot open display: :0

The most straightforward workaround is to use xhost to temporarily allow the root user to access the local user’s X session.

To do so, run command:

xhost si:localuser:root

After running the command, these graphical applications can be launched from app launcher or via sudo, gksu, pkexec commands until you log out.

To make this work automatically at login, search for and launch Startup Applications utility, click the “Add” button to run the command at startup:

  • name: whatever
  • command: xhost si:localuser:root
  • comment: whatever

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via ubuntuhandbook1@gmail.com Buy me a coffee: Buymeacoffee | https://ko-fi.com/ubuntuhandbook1 |

31 responses to Ubuntu 17.10 Tip: Graphical Apps Doesn’t Launch via Root, Sudo, Gksu

  1. You can also use xhost + to allow and xhost – to return it to the default state.

  2. Thanks a lot !!

  3. You are the boss!

  4. Thanks a lot! You saved me a lot of time!

  5. Great! Do you think this is just a short term fix?

  6. Thank you man! I finally found a solution after a whole day of searching the web. I tried everything but nothing seemed to work.

  7. thanks, it works for me!

  8. Thanks, saved me hours of work. All the best, Caravaglia

  9. Here are some workarounds that I use…

    Gedit: use ‘sudo -e’ which copies the file to a temporary location, edits it, then copies it back

    Gparted: use the Gnome ‘disks’ which is installed by default

    Synaptic Package Manager: use ‘apt show ‘ and ‘apt list **’

  10. HI, need help…cannot start Unetbootin with this workaround…any idea? Thx

    Dan

    • Unetbootin is an exception. However, it should launch via terminal command:

      sudo unetbootin

      Or leave Wayland and select login with session ‘Ubuntu on Xorg’.

      • HI, thx a lot!

        my system seems to be f*ed up… with sudo I see an empty unetbootin box and get a multitude of error messages in terminal (invalid shared segment parameter)

        and (after installing and deinstalling many desktops to play) I dont have the option of x.org anymore

        hmmmm…

        can I reinstall 17.10 without overwriting everything?

        Thx a lot

        Dan

        • Reinstalling Ubuntu overwrites everything, unless you installed /home in a separate partition.

          Try timeshift to create system restore point, so you can easily restore your Ubuntu to original status after messing it up.

    • It took me trying just about everything I could think of; (hehe, I couldn’t resist) “on Earth, and throughout Heaven above; but, after about (and significant amounts of hair pulling) three hours, I finally found “a” (at least; at the very “minimum requirements” baseline; necessarily, only for Unetbootin, and only one single instance) productive workaround. I don’t know how long it’ll continue to work’; the full GUI of Unetbootin, is presently running, as I’m typing this response, but for how long ——- I make no promises; but it’s working right now, and that’s good enough for me.

      • Now; suffice to say; I tried a number of different things, but the specific combination of thing, that I think did it for me, are/were: 1. I installed Gnome-Panel; 2. I logged out, then immediately (without restarting my computer) back in, which; I can only guess, inferring from my observation’s; forced the system to use Xorg, instead of wayland; 3. Finally, I edited the command, of the Startup Menu entry, for Unetbootin, to use the code (/usr/bin/unetbootin ‘rootcheck=no’) of the original error I got, while trying to run from the Terminal, with user @Ji m’s previous suggestion.

  11. Jakub Sobolewski November 10, 2017 at 8:28 pm

    Thank you! This post is exactly what i was looking for for last 30 minutes.

  12. Bleachbit doesn’t work.

  13. Thank you! It works for me!

  14. Hello Ji m,
    I tried the above command but it says
    No Protocol Specified
    xhost: unable to open display “:0”

    Please help me

  15. $ sudo -H nautilus
    $ pkexec nautilus
    $ nautilus admin:///

  16. Thanks works like a charm !!!

  17. 你好
    多谢
    .
    Bonjour,
    Merci beaucoup.
    (fr)

  18. Doesn’t work at all. xhost si:localuser:root simply gives a bunch of “out of bounds” errors and other gobbledygook, and nothing changes.

  19. That’s great thank you bleach bit it’s working.

  20. Please – Can you help?

    xhost si:localuser:root
    No protocol specified
    xhost: unable to open display “:0”

    it doesn’t work for me.

  21. I find this version of Ubuntu to have many unresolved bugs. I do not think it is at standard to be released into the wild unless you much have time to waste finding bug solutions. I have decided to remove this version.

  22. it worked for me ,thanx

  23. Still Same Error
    /home/hamza/Pictures/Screenshot from 2018-04-03 23-43-38.png

  24. Just found this post. I tried this on my computer and it worked for me! Now, I can run Synaptic Package Manager again. Thanks!

  25. Awesome! Thanks mate