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

October 11, 2017 — 22 Comments

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

I'm a freelance blogger who started using Ubuntu 5+ years ago and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me on Google Plus or email to ubuntuhandbook1@gmail.com

22 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.

  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.

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

*